Changeset 180 for trunk/foundation/class_c/nomfilepath.c
- Timestamp:
- Jan 7, 2007, 5:27:39 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/foundation/class_c/nomfilepath.c
r146 r180 52 52 input the resulting path may not be valid. 53 53 54 The method returns the NOMPath instanceafter appending.54 The method returns a new NOMPath after appending. 55 55 */ 56 56 NOM_Scope PNOMPath NOMLINK impl_NOMPath_appendPath(NOMPath* nomSelf, const PNOMPath nomPath, CORBA_Environment *ev) … … 59 59 60 60 if(!nomPath) 61 return nomSelf;61 return (PNOMPath)NOMPath_copy(nomSelf, NULLHANDLE); 62 62 63 63 if(0==NOMPath_length((NOMString*)nomPath, ev)) … … 69 69 NOMPath_appendSeparator(nomSelf, ev); /* Make sure current path has a separator */ 70 70 71 return (NOMPath*) NOMPath_append String((NOMString*) nomSelf, (NOMString*)nomPath, NULLHANDLE);71 return (NOMPath*) NOMPath_append((NOMString*) nomSelf, (NOMString*)nomPath, NULLHANDLE); 72 72 } 73 73 74 74 /* 75 75 Append a separator to the path. If the path already has a separator at the end this method does 76 nothing other than returning the path. 76 nothing other than returning a new path object. If the given path has zero length a path object 77 only holding a separator is returned. 78 79 This method always returns a new instance of a NOMPath owned by the caller. 77 80 */ 78 81 NOM_Scope PNOMPath NOMLINK impl_NOMPath_appendSeparator(NOMPath* nomSelf, CORBA_Environment *ev) … … 80 83 gchar* chrTemp; 81 84 gulong len; 82 85 83 86 if((len=NOMPath_length((NOMString*)nomSelf, ev))==0) 84 87 return (NOMPath*)NOMPath_appendCString((NOMString*)nomSelf, G_DIR_SEPARATOR_S, ev); … … 87 90 return (NOMPath*)NOMPath_appendCString( (NOMString*)nomSelf, G_DIR_SEPARATOR_S, ev); 88 91 89 return nomSelf;92 return (PNOMPath)NOMPath_copy(nomSelf, NULLHANDLE); 90 93 } 91 94 92 95 /* 93 96 Strips the path separator from the end of a path if there's one. 97 98 This method always returns a new instance of a NOMPath owned by the caller. 94 99 */ 95 100 NOM_Scope PNOMPath NOMLINK impl_NOMPath_stripSeparator(NOMPath* nomSelf, CORBA_Environment *ev) … … 98 103 gulong len; 99 104 100 if((len=NOMPath_length((NOMString*)nomSelf, ev))==0) 101 return nomSelf; 102 103 chrTemp=NOMPath_getCString((NOMString*)nomSelf, ev); 105 if((len=NOMPath_length((NOMString*)nomSelf, NULLHANDLE))==0) 106 return (PNOMPath)NOMPath_copy(nomSelf, NULLHANDLE); 107 108 chrTemp=NOMPath_queryCString((NOMString*)nomSelf, NULLHANDLE); 109 104 110 if(chrTemp[len-1]==G_DIR_SEPARATOR) 105 return (NOMPath*)NOMPath_truncateString( (NOMString*)nomSelf, len-1, ev); 106 107 return nomSelf; 108 } 111 return (NOMPath*)NOMPath_truncate( (NOMString*)nomSelf, len-1, NULLHANDLE); 112 113 return (PNOMPath)NOMPath_copy(nomSelf, NULLHANDLE); 114 } 115 116 /* 117 Returns TRUE if the given path is absolute. 118 On OS/2 this means it starts with a letter followed by a colon. 119 */ 120 NOM_Scope CORBA_boolean NOMLINK impl_NOMPath_pathIsAbsolute(NOMPath* nomSelf, CORBA_Environment *ev) 121 { 122 /* NOMPathData* nomThis=NOMPathGetData(nomSelf); */ 123 gchar* chrString; 124 125 #ifndef __OS2__ 126 #error !!!!! Only implemented for OS/2 !!!!! 127 #endif 128 129 if(NOMPath_length(nomSelf, NULLHANDLE)<2) 130 return FALSE; 131 132 chrString=NOMPath_queryCString(nomSelf, NULLHANDLE); 133 134 if(!g_ascii_isalpha(chrString[0]) || chrString[1]!=':') 135 return FALSE; 136 137 return TRUE; 138 } 139 140 NOM_Scope PNOMPath NOMLINK impl_NOMPath_queryRoot(NOMPath* nomSelf, CORBA_Environment *ev) 141 { 142 /* NOMPathData* nomThis=NOMPathGetData(nomSelf); */ 143 PNOMPath nomRetval=(PNOMPath)NOMPath_new(nomSelf, NULLHANDLE); 144 gchar os2Root[4]="a:"; /* includes padding */ 145 gchar *chrTemp; 146 147 #ifndef __OS2__ 148 #error !!!!! Only implemented for OS/2 !!!!! 149 #endif 150 151 if(!NOMPath_pathIsAbsolute(nomSelf, NULLHANDLE)) 152 return nomRetval; /* Return a zero length string */ 153 154 chrTemp=NOMPath_queryCString(nomSelf, NULLHANDLE); 155 156 os2Root[0]=chrTemp[0]; 157 return (PNOMPath) NOMPath_assignCString(nomRetval, os2Root, NULLHANDLE); 158 } 159 160 /* 161 This method strips all characters from the beginning of a path till the first 162 directory separator and also this first separator. If there's no separator in 163 the path a zero length path is returned. 164 165 This method always returns a new instance of a NOMPath owned by the caller. 166 */ 167 NOM_Scope PNOMPath NOMLINK impl_NOMPath_erasePathBegin(NOMPath* nomSelf, CORBA_Environment *ev) 168 { 169 /* NOMPathData* nomThis=NOMPathGetData(nomSelf); */ 170 PNOMPath nomRetval=(PNOMPath) NOMPath_new(nomSelf, NULLHANDLE); 171 gchar *chrTemp; 172 173 chrTemp=NOMPath_queryCString(nomSelf, NULLHANDLE); /* Not a copy */ 174 175 while(*chrTemp!='\0' && *chrTemp!=G_DIR_SEPARATOR) 176 chrTemp++; 177 178 if(*chrTemp==G_DIR_SEPARATOR) 179 chrTemp++; 180 181 return (PNOMPath)NOMPath_assignCString(nomRetval, chrTemp, NULLHANDLE); 182 } 183 184 /* 185 Returns the part of the path up to the first directory separator ('\' on OS/2). 186 If there's no directory separator the whole path is returned. This method does 187 not remove the part from the given path. Use erasePathBegin() to do that. 188 */ 189 NOM_Scope PNOMPath NOMLINK impl_NOMPath_queryPathBegin(NOMPath* nomSelf, CORBA_Environment *ev) 190 { 191 /* NOMPathData* nomThis=NOMPathGetData(nomSelf); */ 192 PNOMPath nomRetval=NOMPathNew(); 193 gchar *chrTemp; 194 195 chrTemp=NOMPath_copyCString(nomSelf, NULLHANDLE); /* This is a copy */ 196 197 while(*chrTemp!='\0' && *chrTemp!=G_DIR_SEPARATOR) 198 chrTemp++; 199 *chrTemp='\0'; 200 201 nomRetval=(PNOMPath)NOMPath_assignCString(nomRetval, chrTemp, NULLHANDLE); 202 203 g_free(chrTemp); 204 return (PNOMPath) nomRetval; 205 } 206
Note:
See TracChangeset
for help on using the changeset viewer.