[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Monotone-devel] Killing off boost::fs
From: |
Richard Levitte - VMS Whacker |
Subject: |
Re: [Monotone-devel] Killing off boost::fs |
Date: |
Mon, 01 Aug 2005 08:13:22 +0200 (CEST) |
In message <address@hidden> on Fri, 29 Jul 2005 20:49:33 -0700, Nathaniel Smith
<address@hidden> said:
njs> Some thoughts on how to do this:
njs> - right now we have types "file_path" (a versionable path),
njs> "local_path" (a path within the working dir -- difference
njs> from file_path is that local_path's can begin "MT/"), and
njs> fs::path (a generic, points-anywhere path). All are stored
njs> as strings, and have constructors that silently normalize,
Where do I find documentation on fs::path? All I can find is
boost::filesystem, and I'd like to know what the relationship between
the two is.
Speaking of which, is boost::filesystem interesting to look into?
njs> - I suggest three slightly different types -- file_path (same as
njs> now), system_path (same as old fs::path, which is a boost type
njs> used directly), and bookkeeping_path (which is a path that _does_
njs> begin with "MT/"). I.e., there is no reason for local_path to be
njs> a superset of file_paths.
njs> - one should not be able to instantiate a file_path directly.
njs> Instead there should be two constructors; one that takes (and
njs> requires) an already-normalized path, and one that takes an
njs> unnormalized path and normalizes it. Doing this allows us to
njs> be more secure, and probably also faster, when dealing with
njs> important contexts (e.g., parsing revisions) where we _know_
njs> that the path should be normalized already.
I assume that in this case, you're not talking about the constructor
methods, but about separate functions. Otherwise, I don't quite
understand what you mean with "not be able to instantiate a file_path
directly".
Speaking of normalised and not normalised, can't we simply assume that
all paths we get as input aren't normalised?
BTW, I assume that with "normalised", you're talking about removal of
../ when possible, tilde-expansion, compression of a sequence of / to
one /, things like that.
njs> - it might also make sense to have these constructors take care
njs> of the prefixing required to deal with calling monotone in a
njs> subdirectory
So basically, you want the notion of the top of a work directory tree.
njs> - the bookkeeping_path constructor should require an
njs> already-normalized path that begins "MT/", since we always
njs> generate these internally anyway.
njs> - system_path (maybe needs a better name?) should always be
njs> absolutified and tilde-expanded, and otherwise do not need to
njs> be verified.
Do we want any path to be tilde-expanded, or just the system_path?
njs> - all this code needs to be done very, very carefully, because
njs> bugs in path normalization/checking can easily lead to
njs> security exploits.
njs>
njs> We don't need many actual operations on these:
njs> - write file
njs> - read file
Uhm, just a small thing here; there already is iostream, so I'm going
to assume you really mean "open", or possibly even just method that
returns a localised string that represents the path to be used with
normal iostream operations and whatnot. Actual writing and reading
should be left to iostream, IMHO.
njs> - file_path: split into components (might be able to optimize
njs> this if we have our own library, e.g. do it during the
njs> normalization pass?)
I think it should be done early, yes.
njs> These should probably take care of i18n implicitly (filenames are
njs> represented as UTF-8 when normalized, but may not be when entered
njs> on the command line or in the filesystem).
Cheers,
Richard
-----
Please consider sponsoring my work on free software.
See http://www.free.lp.se/sponsoring.html for details.
--
Richard Levitte address@hidden
http://richard.levitte.org/
"When I became a man I put away childish things, including
the fear of childishness and the desire to be very grown up."
-- C.S. Lewis
- Re: [Monotone-devel] Killing off boost::fs,
Richard Levitte - VMS Whacker <=