Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | Nobody <nobody@nowhere.com> |
|---|---|
| Subject | Re: Representing a hierarchical file system |
| Date | 2011-08-16 11:45 +0100 |
| Message-Id | <pan.2011.08.16.10.45.24.199000@nowhere.com> |
| Newsgroups | comp.lang.c |
| References | <j2as5n$4gl$1@speranza.aioe.org> <chine.bleu-2A8469.10350815082011@news.eternal-september.org> <j2bm0p$14f$3@speranza.aioe.org> |
| Organization | Zen Internet |
On Mon, 15 Aug 2011 19:46:03 +0200, jacob navia wrote: > I would rather ignore links, and avoid anything Unix specific (or DOS > specific) > > Just a simple hierarchical representation with some attibutes like size > and time > > I would like it to be as portable as possible These are self-contradictory. If you /really/ ignore links then, on Unix, your filesystem will be empty; a Unix filesystem is nothing but links. A common Unix noob mistake is asking how to identify or distinguish a hard link (i.e. something created by link()) from a "real" file. This is a meaningless question; a hard link is just a directory entry; the links created by "ln" are no different to those created when the file itself was originally created with open() or creat(). You can only create a "hierarchical representation" of a Unix filesystem by losing the distinction between a (hard) link and the file to which it refers, so you can't distinguish between N links to a single file and N distinct files. On the bright side, modern Unices don't normally allow creating hard links to directories, so you can't have cycles (assuming that you ignore the "." and ".." links). If you just discard symbolic links, many filenames will simply be invalid according to your representation, which is likely to impair its utility. OTOH, if you treat symbolic links as synonymous with the object to which they refer, not only will your representation not be hierarchical, it will probably be cyclic (if you actually manage to construct it without going into infinite recursion). [Actually, you can end up going into infinite recursion anyhow, if you try to traverse a directory tree without explicitly checking for loops, as directories can be renamed (i.e. moved) at any time.] If you want portability, you really have to support the key features of all of the target systems (i.e. the common superset, not the common subset). So e.g. if you want to support Unix, the data model has to support the concepts of hard and symbolic links. On Windows, these will still exist as concepts, but you just won't encounter any in practice.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Representing a hierarchical file system jacob navia <jacob@spamsink.net> - 2011-08-15 12:24 +0200
Re: Representing a hierarchical file system Ian Collins <ian-news@hotmail.com> - 2011-08-15 22:36 +1200
Re: Representing a hierarchical file system jacob navia <jacob@spamsink.net> - 2011-08-15 19:43 +0200
Re: Representing a hierarchical file system Keith Thompson <kst-u@mib.org> - 2011-08-15 09:23 -0700
Re: Representing a hierarchical file system David Thompson <dave.thompson2@verizon.net> - 2011-08-21 03:22 -0400
Re: Representing a hierarchical file system Nobody <nobody@nowhere.com> - 2011-08-15 18:02 +0100
Re: Representing a hierarchical file system jacob navia <jacob@spamsink.net> - 2011-08-15 19:44 +0200
Re: Representing a hierarchical file system China Blue Tip Wrench <chine.bleu@yahoo.com> - 2011-08-15 10:35 -0700
Re: Representing a hierarchical file system jacob navia <jacob@spamsink.net> - 2011-08-15 19:46 +0200
Re: Representing a hierarchical file system "Heinrich Wolf" <invalid@invalid.invalid> - 2011-08-15 20:31 +0200
Re: Representing a hierarchical file system Ian Collins <ian-news@hotmail.com> - 2011-08-16 08:32 +1200
Re: Representing a hierarchical file system Nobody <nobody@nowhere.com> - 2011-08-16 11:45 +0100
Re: Representing a hierarchical file system BGB <cr88192@hotmail.com> - 2011-08-16 04:00 -0700
csiph-web