Changes between Version 6 and Version 7 of PathnamesCowan


Ignore:
Timestamp:
03/23/11 00:20:45 (7 years ago)
Author:
cowan
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PathnamesCowan

    v6 v7  
    3131All of these components can also be `#f` to indicate that the component is not present.  In particular, a filename or URI ending in `/` or `\` will result in the file and type components being `#f`. 
    3232 
    33 == The path separator parameter == 
    34  
    35 `(pathname-syntax [value]`) 
    36  
    37 This is a (SRFI 39) parameter whose value is either `windows` or `posix`, and is used to define whether parsing and construction of filenames uses Windows or Posix syntax.  It may have other values, but the result is implementation defined.  The initial value is also implementation-defined. 
    38  
    39 == Basic procedures == 
    40  
    41 The procedures `pathname?` and `pathname=?` do what you expect.  Note that two pathnames may be different according to `pathname=?` but still access the same resource.  Host components are compared case-insensitively. 
    42  
    4333== Accessors == 
    4434 
     
    5141`(make-pathname `''components''`)` 
    5242 
    53 Constructs and returns a pathname.  ''Components'' is an a-list mapping component names to values.  Component names not defined in this specification are allowed, but the results are implementation-specific.  Any component names not appearing in ''components'' are set to `#f`. 
     43Constructs and returns a pathname.  ''Components'' is an a-list mapping component names (as symbols) to values.  Component names not defined in this specification are allowed, but the results are implementation-specific.  Any component names not appearing in ''components'' are set to `#f`. 
     44 
     45ISSUE: Should `make-pathname` accept multiple arguments rather than a single argument which is an a-list?  Variable a-lists can be constructed by quasiquotation. 
    5446 
    5547The following procedures accept a string and construct and return a pathname corresponding to that string. 
    5648 
    57 `(filename->pathname `''filename''`)` 
     49`(posix-filename->pathname `''filename''`)` 
    5850 
    59 Constructs and returns a pathname.  ''Filename'' is a string to be converted to a filename. 
     51Constructs and returns a pathname.  ''Filename'' is a string representing a Posix filename. 
    6052 
    61 If `(pathname-syntax)` is `posix`, then ''filename'' is parsed using `/` as the component separator, the directory, name, and type components are potentially populated from it, and the device component is set to `#f`. 
     53''Filename'' is parsed using `/` as the component separator.  The directory, name, and type components are potentially populated from it, and the device component is set to `#f`. 
    6254 
    63 If `(pathname-syntax)` is `windows`, then ''filename'' is parsed using both `\` and `/` as component separators, a leading `//` or `\\` results in a directory component beginning with `unc`, and the device, directory, name, and type components are potentially populated from it. 
     55The scheme component is set to `"file"`, and the username, password, port, query, and fragment components are set to `#f`. 
    6456 
    65 Finally, the scheme component is set to `"file"`, and the username, password, port, query, and fragment components are set to `#f`. 
     57`(posix-dirname->pathname `''dirname''`)` 
     58 
     59Constructs and returns a pathname.  ''Dirname'' is a string representing a Posix directory name. 
     60 
     61''Filename'' is parsed using `/` as the component separator.  The directory component is potentially populated from it. 
     62 
     63The scheme component is set to `"file"`, and the username, password, port, device, name, type, query, and fragment components are set to `#f`. 
     64 
     65`(windows-filename->pathname `''filename''`)` 
     66 
     67Constructs and returns a pathname.  ''Filename'' is a string representing a Windows filename. 
     68 
     69''Filename'' is parsed using both `\` and `/` as component separators, and a leading `//` or `\\` results in a directory component whose ''car'' is `unc`.  The device and directory, name, and type components are potentially populated from it. 
     70 
     71The scheme component is set to `"file"`, and the username, password, port, query, and fragment components are set to `#f`. 
     72 
     73`(windows-dirname->pathname `''dirname''`)` 
     74 
     75Constructs and returns a pathname.  ''Dirname'' is a string representing a Windows directory name. 
     76 
     77''Filename'' is parsed using both `\` and `/` as component separators, and a leading `//` or `\\` results in a directory component whose ''car'' is `unc`.  The device and directory components are potentially populated from it. 
     78 
     79The scheme component is set to `"file"`, and the username, password, port, name, type, query, and fragment components are set to `#f`. 
    6680 
    6781`(uri->pathname `''uri''`)` 
     
    6983Constructs and returns a pathname.  ''Uri'' is a string to be converted to a pathname.  It is parsed according to IRI rules, which are the same as URI rules except that sequences of `%`-hexdigit-hexdigit escapes that represent UTF-8 byte sequences are parsed into characters, provided the requisite characters are supported by the implementation. 
    7084 
    71 The scheme, host, port, username, password, directory, name, type, query, and fragment components are potentially populated from ''uri''.  The device component is set to `#f`.  If the query part of the IRI consists of name-value pairs separated by `&` or `;` and with `=` between the name and the value, then the query component will be an a-list of strings; otherwise, it will just be a string. 
     85The scheme, host, port, username, password, directory, name, type, query, and fragment components are potentially populated from ''uri''.  The device component is set to `#f`. 
    7286 
    7387== Deconstructors == 
     
    7589The following procedures accept a pathname and construct and return a string corresponding to that pathname. 
    7690 
    77 `(pathname->filename `''pathname''`)` 
     91`(pathname->posix-filename `''pathname''`)` 
    7892 
    7993Constructs and returns a filename string from ''pathname''. 
    8094 
    81 If `(pathname-syntax)` is `posix`, then the result is constructed using `/` as the component separator from the directory, name, and type components of ''pathname''. 
     95The result is constructed using `/` as the component separator from the directory, name, and type components of ''pathname''. 
    8296 
    83 If `(pathname-syntax)` is `windows`, then the result is constructed using `\` as the component separator from the device, directory, name, and type components. 
     97It is an error if the username, password, port, query, and fragment components are not `#f`.  It is an error if the scheme component is not `"file"` or `#f`. 
    8498 
    85 It is an error if the username, password, port, query, and fragment components are not `#f`.  It is an error if the scheme component is not `"file"`. 
     99`(pathname->posix-filename `''pathname''`)` 
     100 
     101Constructs and returns a filename string from ''pathname''. 
     102 
     103The result is constructed using `\` as the component separator from the device, directory, name, and type components. 
     104 
     105It is an error if the username, password, port, query, and fragment components are not `#f`.  It is an error if the scheme component is not `"file"` or `#f`. 
     106 
     107`(pathname->iri `''pathname''`)` 
     108 
     109Constructs and returns a string according to RFC 3987 rules.  No escaping of non-ASCII characters is done. 
     110 
     111The scheme, host, port, username, password, directory, name, type, query, and fragment components are used to construct the URI.  It is an error if the device component is not `#f`, or if the first element of the directory component is not `absolute`. 
     112 
     113`(pathname-directory->posix-dirname `''pathname''`)` 
     114 
     115Returns ''pathname'' as a Posix directory string.  The result consists of the strings in the ''cdr'' of the directory component joined using `/` with another `/` prepended if the ''car'' is `absolute`. 
     116  
     117`(pathname-directory->window-dirname `''pathname''`)` 
     118 
     119Returns the ''pathname'' as a Windows directory string.  The result consists of the strings in the ''cdr'' of the directory component joined using `\`, prefixed by one of the following: 
     120 
     121 * `\` if the ''car'' of the directory component is `absolute` 
     122 
     123 * `\\` followed by the host component if the ''car'' of the directory component is `unc` 
     124 
     125 * the device followed by `:` if the device component is not `#f` 
     126 
     127 * the empty string otherwise 
    86128 
    87129`(pathname->uri `''pathname''`)` 
     
    91133The scheme, host, port, username, password, directory, name, type, query, and fragment components are used to construct the URI.  It is an error if the device component is not `#f`, or if the `car` of the directory component is not `absolute`. 
    92134 
    93 `(pathname->iri `''pathname''`)` 
     135== Other procedures == 
    94136 
    95 Constructs and returns a string according to RFC 3987 rules.  No escaping of non-ASCII characters is done. 
     137`(pathname? ''object''`)` 
    96138 
    97 The scheme, host, port, username, password, directory, name, type, query, and fragment components are used to construct the URI.  It is an error if the device component is not `#f`, or if the `car` of the directory component is not `absolute`. 
     139Returns `#t` if ''object'' is a pathname, and `#f` otherwise. 
    98140 
    99 == Other procedures == 
     141`(pathname=` ''pathname1''` `''pathname2''`)` 
     142 
     143Compares ''pathname1'' and ''pathname2'' for equality, component-wise.  Note that two pathnames may be different according to `pathname=?` but still access the same resource.  The host components are compared case-insensitively. 
    100144 
    101145`(merge-pathnames `''pathname1''` `''pathname2''`)` 
     
    105149`(pathname-absolute-filename? `''pathname''`)` 
    106150 
    107 Returns `#t` if ''pathname'' specifies an absolute or UNC filename.  If `(pathname-syntax)` is `windows`, the device component must be specified. 
     151Returns `#t` if ''pathname'' specifies an absolute or UNC filename. 
    108152 
    109153`(pathname-absolute-uri? `''pathname''`)` 
     
    119163Returns the query component of ''pathname'' as an a-list, where `&` and `;` separate the entries in the alist, and `=` separates the `car` from the `cdr`. 
    120164 
    121 `(pathname-directory->string `''pathname''`)` 
    122  
    123 Returns the directory component of ''pathname'' as a string.  The result consists of the strings in the ''cdr'' of the directory component joined using the path separator, with the separator prepended if the ''car'' is `absolute`.  If `(pathname-syntax)` is `posix`, the path separator is `/`; if `(pathname-syntax)` is `windows`, the path separator is `\`.