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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 535 - (show annotations) (download) (as text)
Tue Apr 25 14:55:48 2006 UTC (14 years, 3 months ago) by johnpye
File MIME type: text/x-chdr
File size: 3231 byte(s)
Little more progress on the ospath stuff. Hoping that this can be used to refactor the module (a4c) and external library (.so/.dll) search methods. Still some bugs though.
1 /* ASCEND modelling environment
2 Copyright (C) 2006 Carnegie Mellon University
3
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2, or (at your option)
7 any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA.
18 *//**
19 @file
20 Operating system file-path manipulations, alla python os.path
21
22 Based on C++ code from codeproject.com written by Simon Parkinson-Bates
23 */
24
25 #ifndef OSPATH_H
26 #define OSPATH_H
27
28 #include <string.h>
29 #include <malloc.h>
30
31 #define PATHMAX 1024
32
33 struct FilePath;
34
35 struct FilePath *ospath_new(const char *path);
36
37 struct FilePath *ospath_new_from_posix(char *posixpath);
38
39 /**
40 Is the path valid? Returns true if so, false otherwise
41 */
42 int ospath_isvalid(struct FilePath *fp);
43
44 /**
45 Cast to string (char *)
46 (you must free the string when you don't need it any more)
47 */
48 char *ospath_str(struct FilePath *fp);
49
50 /**
51 Output string-cast to FILE
52 */
53 void ospath_fwrite(struct FilePath *fp, FILE *dest);
54
55 void ospath_debug(struct FilePath *fp, char *label);
56
57 /**
58 Return length of path string
59 */
60 unsigned int ospath_length(struct FilePath *fp);
61
62 /**
63 Create a new path that is the direct parent of this one
64 */
65 struct FilePath *ospath_getparent(struct FilePath *fp);
66
67 /**
68 Return a new path object which is a parent path of the current path up to the specified depth.
69 If the specifed depth is >= to the current path's depth, then a copy of the current path object is returned.
70
71 ie.
72 FilePath("/lev1/lev2/lev3/lev4/lev5").GetParentAtDepthN(3).c_str()
73 returns
74 "/lev1/lev2/lev3/"
75 */
76 struct FilePath *ospath_getparentatdepthn(struct FilePath *fp, unsigned nDepth);
77
78 /**
79 Return then name of the bottom most level path entry (includes any extension)
80 */
81 char *ospath_getbasefilename(struct FilePath *fp);
82
83 /**
84 retrieve the path's bottom level filename with out the extension
85 */
86 char *ospath_getbasefiletitle(struct FilePath *fp);
87
88 /**
89 retrieve the paths extension (if it has one) does not include the dot
90 */
91 char *ospath_getbasefileextension(struct FilePath *fp);
92
93 /**
94 Function returns true if the current path is the root directory, otherwise it returns false.
95 */
96 int ospath_isroot(struct FilePath *fp);
97
98 /**
99 Return the current paths' depth
100 ie. "/usr/some directory with spaces in it/hello"
101 returns a depth value of 3
102 */
103 unsigned ospath_depth(struct FilePath *fp);
104
105 /**
106 Return the root path
107 */
108 struct FilePath *ospath_root(struct FilePath *fp);
109
110 int ospath_cmp(struct FilePath *fp1, struct FilePath *fp2);
111
112 struct FilePath *ospath_concat(struct FilePath *fp1, struct FilePath *fp2);
113
114 void ospath_append(struct FilePath *fp, struct FilePath *fp1);
115
116
117 #endif

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