/[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 541 by johnpye, Wed Apr 26 07:32:13 2006 UTC revision 542 by johnpye, Wed Apr 26 15:15:40 2006 UTC
# Line 31  Line 31 
31    
32  #ifndef OSPATH_H  #ifndef OSPATH_H
33  #define OSPATH_H  #define OSPATH_H
34    
35    #ifndef PATH_MAX
36    # define PATH_MAX 1023
37    #endif
38    
39  struct FilePath;  struct FilePath;
40    
# Line 63  int ospath_isvalid(struct FilePath *fp); Line 67  int ospath_isvalid(struct FilePath *fp);
67      Return the FilePath in the form of a string.      Return the FilePath in the form of a string.
68      You must FREE the allocated string when you don't need it any more.      You must FREE the allocated string when you don't need it any more.
69  */  */
70  char *ospath_str(struct FilePath *fp);  char *ospath_str(struct FilePath *fp);
71    
72    /**
73        Return the FilePath in the string location given.
74        If the user has allocated a local array before calling ospath_strcpy,
75        then this allows the FREE(dest) call to be avoided.
76    
77        @param dest the location of allocated storage space where the FilePath
78            will be written.
79        @param destsize the amount of allocated string space at dest.
80    */
81    void ospath_strcpy(struct FilePath *fp,char *dest, int destsize);
82    
83  /**  /**
84      Output the FilePath to a file      Output the FilePath to a file
# Line 103  struct FilePath *ospath_getparentatdepth Line 118  struct FilePath *ospath_getparentatdepth
118  char *ospath_getbasefilename(struct FilePath *fp);  char *ospath_getbasefilename(struct FilePath *fp);
119    
120  /**  /**
121      retrieve the path's bottom level filename with out the extension      retrieve the path's bottom level filename without the extension.
122        A path that ends in a slash will be assumed to be directory, so the
123        file stem will be NULL (ie not a file)
124  */  */
125  char *ospath_getbasefiletitle(struct FilePath *fp);  char *ospath_getfilestem(struct FilePath *fp);
126    
127  /**  /**
128      retrieve the paths extension (if it has one) does not include the dot      retrieve the paths extension (if it has one) does not include the dot
129  */  */
130  char *ospath_getbasefileextension(struct FilePath *fp);  char *ospath_getfileext(struct FilePath *fp);
131    
132    /**
133        retrieve the directory component of the path (everything up the the
134        last slash
135    */
136    struct FilePath *ospath_getdir(struct FilePath *fp);
137    
138  /**  /**
139      Function returns true if the current path is the root directory, otherwise it returns false.      Function returns true if the current path is the root directory, otherwise it returns false.
# Line 134  int ospath_cmp(struct FilePath *fp1, str Line 157  int ospath_cmp(struct FilePath *fp1, str
157  struct FilePath *ospath_concat(struct FilePath *fp1, struct FilePath *fp2);  struct FilePath *ospath_concat(struct FilePath *fp1, struct FilePath *fp2);
158    
159  void ospath_append(struct FilePath *fp, struct FilePath *fp1);  void ospath_append(struct FilePath *fp, struct FilePath *fp1);
160    
161    /**
162        File-open function. Simply a wrapper about the 'fopen' call, except
163        that if the FilePath is not 'valid' it will return NULL without
164        attempting to open.
165    */
166    FILE *ospath_fopen(struct FilePath *fp, const char *mode);
167    
168  //------------------------  //------------------------
169  // SEARCH PATH FUNCTIONS  // SEARCH PATH FUNCTIONS
170    
171  struct FilePath **ospath_searchpath_new(char *path);  struct FilePath **ospath_searchpath_new(const char *path);
172    
173  typedef int (FilePathTestFn)(struct FilePath *,void *);  typedef int (FilePathTestFn)(struct FilePath *,void *);
174    

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

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