/[ascend]/trunk/base/generic/general/ospath.h
ViewVC logotype

Diff of /trunk/base/generic/general/ospath.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 540 by johnpye, Tue Apr 25 14:55:48 2006 UTC revision 541 by johnpye, Wed Apr 26 07:32:13 2006 UTC
# Line 17  Line 17 
17      Boston, MA 02111-1307, USA.      Boston, MA 02111-1307, USA.
18  *//**  *//**
19      @file      @file
20      Operating system file-path manipulations, alla python os.path      A C-language class for simple file-path manipulations alla python os.path.
21        Attempts to handle windows 'drive' prefixes (eg "C:") and automatic
22        substitution of forward slashes with appropriate platform-specific
23        path separators.
24    
25      Based on C++ code from codeproject.com written by Simon Parkinson-Bates      Has the goal of providing path-search functionality to ASCEND for
26        modules (a4c) and external library (.dll) files, etc.
27    
28        Heavily modified version of C++ code from codeproject.com
29        originally written by Simon Parkinson-Bates.
30  */  */
31    
32  #ifndef OSPATH_H  #ifndef OSPATH_H
33  #define OSPATH_H  #define OSPATH_H
34    
 #include <string.h>  
 #include <malloc.h>  
   
 #define PATHMAX 1024  
   
35  struct FilePath;  struct FilePath;
36    
37    /**
38        Create a new ospath object from a string. This will
39        normalise the path and attempt to add a drive-prefix
40        if one is missing.
41    */
42  struct FilePath *ospath_new(const char *path);  struct FilePath *ospath_new(const char *path);
43    
44    /**
45        Free an ospath
46    */
47    void ospath_free(struct FilePath *);
48    
49    /**
50        Create a new ospath object from a string, assuming
51        that standard forward-slash paths are used.
52    */
53  struct FilePath *ospath_new_from_posix(char *posixpath);  struct FilePath *ospath_new_from_posix(char *posixpath);
54    
55  /**  /**
56      Is the path valid? Returns true if so, false otherwise      Check that the created FilePath was valid (i.e. able
57        to be parsed. Doesn't check that the directory/file
58        actually exists.)
59  */  */
60  int ospath_isvalid(struct FilePath *fp);  int ospath_isvalid(struct FilePath *fp);
61    
62  /**  /**
63      Cast to string (char *)      Return the FilePath in the form of a string.
64      (you must free the string when you don't need it any more)      You must FREE the allocated string when you don't need it any more.
65  */  */
66  char *ospath_str(struct FilePath *fp);  char *ospath_str(struct FilePath *fp);
67    
68  /**  /**
69      Output string-cast to FILE      Output the FilePath to a file
70  */  */
71  void ospath_fwrite(struct FilePath *fp, FILE *dest);  void ospath_fwrite(struct FilePath *fp, FILE *dest);
72    
73  void ospath_debug(struct FilePath *fp, char *label);  /**
74        Write out the internal structure of the FilePath object
75        to stderr.
76    */
77    void ospath_debug(struct FilePath *fp);
78    
79  /**  /**
80      Return length of path string      Return length of path string
# Line 60  void ospath_debug(struct FilePath *fp, c Line 82  void ospath_debug(struct FilePath *fp, c
82  unsigned int ospath_length(struct FilePath *fp);  unsigned int ospath_length(struct FilePath *fp);
83    
84  /**  /**
85      Create a new path that is the direct parent of this one      Create a new path that is the direct parent of this one.
86  */  */
87  struct FilePath *ospath_getparent(struct FilePath *fp);  struct FilePath *ospath_getparent(struct FilePath *fp);
88    
# Line 113  struct FilePath *ospath_concat(struct Fi Line 135  struct FilePath *ospath_concat(struct Fi
135    
136  void ospath_append(struct FilePath *fp, struct FilePath *fp1);  void ospath_append(struct FilePath *fp, struct FilePath *fp1);
137    
138    //------------------------
139    // SEARCH PATH FUNCTIONS
140    
141    struct FilePath **ospath_searchpath_new(char *path);
142    
143    typedef int (FilePathTestFn)(struct FilePath *,void *);
144    
145    struct FilePath *ospath_searchpath_iterate(
146            struct FilePath **searchpath
147            , FilePathTestFn *testfn
148            , void *searchdata
149    );
150    
151  #endif  #endif

Legend:
Removed from v.540  
changed lines
  Added in v.541

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22