Re: Reading Text Files



On Sun, 08 Mar 2009 16:49:23 +0000, Richard Heathfield
<rjh@xxxxxxxxxxxxxxx> wrote:

Keith Thompson said:

<snip>

You asked for cases where the use of '/' will fail. I presented
such
a case. Presenting another case where it doesn't fail doesn't
refute that.

True enough.

The context of the question is Windows, and this really is one of
those questions that has far more to do with Windows than it has
with C, and ought properly to be asked in a group such as
comp.os.ms-windows.programmer.win32. As far as C is concerned, the
first argument to fopen is a string that represents a filename on
the host system. If the string doesn't represent such a filename,
fopen cannot possibly open it, right? So it is the programmer's
responsibility to ensure that the filename is valid. Even if
Windows did support forward slashes as a path separator in all
filename contexts, embedding them in a string literal is a silly
idea if the program is to be portable. Some operating systems don't
even have a concept of "path", at least not in the same sense that
Windows does, or Unix does, or Linux does. There are other ways to
organise files than in an open tree.

Consider, for example, MVS, in which filenames consist of digits,
letters, and dots (and you can't have more than eight non-dot
characters in a row). On many sites, the dots are used as if they
were directory separators, but MVS doesn't enforce this.

Furthermore, MVS allows the creation of Partitioned Data Sets
(PDSs), which consist of multiple members, each of which can be
considered a separate file. Thus, the Partitioned Data Set
FOO.BAR.BAZ might have three members, FOO.BAR.BAZ(QUUX),
FOO.BAR.BAZ(QUUUX) and FOO.BAR.BAZ(QUUUUX). Looked at in this way,
the parentheses can be thought of as (paired) "filename
delimiters", but *only* in the context of a PDS.

A portable C program can easily deal with such a system. I know,
because I've written a great many such programs. The trick is to
avoid hard-coding "magic" filenames.

<snip>

Yep. In the early 1990s i dealt with IBM MVS and had to handle things
called generational data sets, which seem to be a variation of
partitioned data sets, whith the current version and a few to hundreds
of previous generations. I had to get special permission to load
something like 220 MB to 250 MB per week into a 5 generation data set.
A couple years later working with VAX VMS with a similar file naming
system that automatically stored backups.

.



Relevant Pages

  • Re: Reading Text Files
    ... those questions that has far more to do with Windows than it has ... If the string doesn't represent such a filename, ... but *only* in the context of a PDS. ...
    (comp.lang.c)
  • Re: Transferring directory structure to Windows
    ... Transferring directory structure to Windows ... Filename collisions are a real threat but it should be ... whether FTP, tar, or whatever, you will only wind up ...
    (AIX-L)
  • Re: listing to a file
    ... batch file but I cannot remember where I found it. ... To create the entry in the context menu it's necessary to first create a ... Save the file in your WINDOWS folder as shown in, ... File Listing will probably be most useful, but you can name yours something ...
    (microsoft.public.windowsxp.general)
  • Re: Characters allowed in short filenames
    ... fatgen103.doc seems to have a slightly below average proportion of bugs, but Windows doesn't completely agree with it. ... > My partial understanding is that short filenames are stored using the> OEM ... > As far as I can tell, code page 437 doesn't contain a ß character. ... > page is 850 then we are halfway towards allowing a short filename to ...
    (microsoft.public.development.device.drivers)
  • Win Explorer Context Menu Queue it up, Add to Playlist NOT WORK
    ... During all this year by now I noticed one big problem with Windows ... Windows Explorer Right click Context menu on multimedia files (e.g. .mp3, ... In the first, I was thinking that maybe some WMP Plug-in, or Visualizations ... start to install more Software on it. ...
    (microsoft.public.windowsmedia.player)