/[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 534 - (show annotations) (download) (as text)
Tue Apr 25 13:25:04 2006 UTC (13 years, 9 months ago) by johnpye
File MIME type: text/x-chdr
File size: 3171 byte(s)
Working on platform-independent pathnames for the IMPORT command.
Added 'ospath.c' to base/generic/general for this purpose.
Patched kvalues and sensitivity to use the 'IMPORT "libname";' syntax
instead of 'IMPORT registerfn FROM libname;'.
Fixed pathnames in create.nsi.
Added GPL header to coupla files.
Added quoting to 'IMPORT' syntax in ascParse.y.
Removed 'PackageOption' from Tcl/Tk related Scons options so that missing Tcl/Tk
doesn't cause breakage.
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 /**
38 Is the path valid? Returns true if so, false otherwise
39 */
40 int ospath_isvalid(struct FilePath *fp);
41
42 /**
43 Cast to string (char *)
44 (you must free the string when you don't need it any more)
45 */
46 char *ospath_str(struct FilePath *fp);
47
48 /**
49 Output string-cast to FILE
50 */
51 void ospath_fwrite(struct FilePath *fp, FILE *dest);
52
53 void ospath_debug(struct FilePath *fp, char *label);
54
55 /**
56 Return length of path string
57 */
58 unsigned int ospath_length(struct FilePath *fp);
59
60 /**
61 Create a new path that is the direct parent of this one
62 */
63 struct FilePath *ospath_getparent(struct FilePath *fp);
64
65 /**
66 Return a new path object which is a parent path of the current path up to the specified depth.
67 If the specifed depth is >= to the current path's depth, then a copy of the current path object is returned.
68
69 ie.
70 FilePath("/lev1/lev2/lev3/lev4/lev5").GetParentAtDepthN(3).c_str()
71 returns
72 "/lev1/lev2/lev3/"
73 */
74 struct FilePath *ospath_getparentatdepthn(struct FilePath *fp, unsigned nDepth);
75
76 /**
77 Return then name of the bottom most level path entry (includes any extension)
78 */
79 char *ospath_getbasefilename(struct FilePath *fp);
80
81 /**
82 retrieve the path's bottom level filename with out the extension
83 */
84 char *ospath_getbasefiletitle(struct FilePath *fp);
85
86 /**
87 retrieve the paths extension (if it has one) does not include the dot
88 */
89 char *ospath_getbasefileextension(struct FilePath *fp);
90
91 /**
92 Function returns true if the current path is the root directory, otherwise it returns false.
93 */
94 int ospath_isroot(struct FilePath *fp);
95
96 /**
97 Return the current paths' depth
98 ie. "/usr/some directory with spaces in it/hello"
99 returns a depth value of 3
100 */
101 unsigned ospath_depth(struct FilePath *fp);
102
103 /**
104 Return the root path
105 */
106 struct FilePath *ospath_root(struct FilePath *fp);
107
108 int ospath_cmp(struct FilePath *fp1, struct FilePath *fp2);
109
110 struct FilePath *ospath_concat(struct FilePath *fp1, struct FilePath *fp2);
111
112 void ospath_append(struct FilePath *fp, struct FilePath *fp1);
113
114
115 #endif

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