diff --git a/sc2/src/sc2code/libs/uio/doc/conventions b/sc2/src/sc2code/libs/uio/doc/conventions index ccc6b0b5e..f15610187 100644 --- a/sc2/src/sc2code/libs/uio/doc/conventions +++ b/sc2/src/sc2code/libs/uio/doc/conventions @@ -5,16 +5,17 @@ This file describes the various conventions used in the source. uio_Thing *uio_Thing_new(args) Allocates the structure, and initialises it from the arguments. - (was: uio_newThing()) + Arguments are always used as-is; if they are reference-counted, + and the caller still needs a reference, it is up to the caller + to increment the reference counter. void uio_Thing_delete(uio_Thing *thing) Frees the structure and all sub-structures. - Decrements references to shared structures. + Decrements reference counters to shared structures. uio_Thing *uio_Thing_alloc() Allocates memory for a new structure. Could be omited for standard allocators. Particularly relevant when a non-standard allocation scheme is used (for instance, allocation from a pool of pre-allocated strucures). - (was: uio_allocThing()) void uio_Thing_free(Thing *thing) Frees the memory allocated for thing (reverse of uio_Thing_alloc). Could be omited for standard deallocators. diff --git a/sc2/src/sc2code/libs/uio/doc/todo b/sc2/src/sc2code/libs/uio/doc/todo index a8b5846da..12b6dddeb 100644 --- a/sc2/src/sc2code/libs/uio/doc/todo +++ b/sc2/src/sc2code/libs/uio/doc/todo @@ -24,14 +24,12 @@ Documentation: The physical close function should delete its own data. It's called Will cleanup the general Handle. Analogous for mount/unmount with PRoot -- (internal) arguments for uio_Bla_new are always copied as-is. - If they are ref-counted, the counter should be incremented by the caller, - if the caller does not need the reference itself. - The uio_Bla_delete function decrements the ref counter of the ref-counted - fields. - No need to store MountHandles. They will be automatically freed when the repository is closed. - You can use mount stuff from other repositories. +- ".." works by nullifying one path component, not by following the ".." link + in the directory. "/a/../b" will always be functionally equivalent to + "/b", even when "/a" is a symlink. Bugs: - 'openDir(repository, "dir/")' will have the trailing '/' diff --git a/sc2/src/sc2code/libs/uio/fileblock.c b/sc2/src/sc2code/libs/uio/fileblock.c index d8f0f6a0a..7b824335c 100644 --- a/sc2/src/sc2code/libs/uio/fileblock.c +++ b/sc2/src/sc2code/libs/uio/fileblock.c @@ -24,9 +24,9 @@ #include -static uio_FileBlock *uio_newFileBlock(uio_Handle *handle, int flags, +static uio_FileBlock *uio_FileBlock_new(uio_Handle *handle, int flags, off_t offset, size_t blockSize, char *buffer, size_t bufSize); -static inline uio_FileBlock *uio_allocFileBlock(void); +static inline uio_FileBlock *uio_FileBlock_alloc(void); static void uio_freeFileBlock(uio_FileBlock *block); @@ -44,7 +44,7 @@ uio_openFileBlock(uio_Handle *handle) { return NULL; } uio_Handle_ref(handle); - return uio_newFileBlock(handle, 0, 0, statBuf.st_size, NULL, 0); + return uio_FileBlock_new(handle, 0, 0, statBuf.st_size, NULL, 0); } uio_FileBlock * @@ -61,7 +61,7 @@ uio_openFileBlock2(uio_Handle *handle, off_t offset, size_t size) { if (statBuf.st_size > #endif uio_Handle_ref(handle); - return uio_newFileBlock(handle, 0, offset, size, NULL, 0); + return uio_FileBlock_new(handle, 0, offset, size, NULL, 0); } // block remains usable until the next call to uio_accessFileBlock @@ -157,11 +157,11 @@ uio_closeFileBlock(uio_FileBlock *block) { // caller should uio_refHandle(handle) (unless it doesn't need it's own // reference anymore). static uio_FileBlock * -uio_newFileBlock(uio_Handle *handle, int flags, off_t offset, +uio_FileBlock_new(uio_Handle *handle, int flags, off_t offset, size_t blockSize, char *buffer, size_t bufSize) { uio_FileBlock *result; - result = uio_allocFileBlock(); + result = uio_FileBlock_alloc(); result->handle = handle; result->flags = flags; result->offset = offset; @@ -172,7 +172,7 @@ uio_newFileBlock(uio_Handle *handle, int flags, off_t offset, } static inline uio_FileBlock * -uio_allocFileBlock(void) { +uio_FileBlock_alloc(void) { return uio_malloc(sizeof (uio_FileBlock)); } diff --git a/sc2/src/sc2code/libs/uio/fstypes.c b/sc2/src/sc2code/libs/uio/fstypes.c index e76773449..43702cab0 100644 --- a/sc2/src/sc2code/libs/uio/fstypes.c +++ b/sc2/src/sc2code/libs/uio/fstypes.c @@ -32,11 +32,11 @@ static uio_bool uio_validFileSystemHandler(uio_FileSystemHandler *handler); -static uio_FileSystemInfo *uio_newFileSystemInfo(uio_FileSystemID id, +static uio_FileSystemInfo *uio_FileSystemInfo_new(uio_FileSystemID id, uio_FileSystemHandler *handler, char *name); static uio_FileSystemInfo **uio_getFileSystemInfoPtr(uio_FileSystemID id); -static inline uio_FileSystemInfo *uio_allocFileSystemInfo(void); +static inline uio_FileSystemInfo *uio_FileSystemInfo_alloc(void); static inline void uio_freeFileSystemInfo(uio_FileSystemInfo *fileSystemInfo); @@ -142,7 +142,7 @@ uio_registerFileSystem(uio_FileSystemID wantedID, const char *name, { uio_FileSystemInfo *newInfo; - newInfo = uio_newFileSystemInfo(wantedID, handler, uio_strdup(name)); + newInfo = uio_FileSystemInfo_new(wantedID, handler, uio_strdup(name)); newInfo->next = *ptr; *ptr = newInfo; return wantedID; @@ -234,11 +234,11 @@ uio_getFileSystemInfoPtr(uio_FileSystemID id) { // sets ref to 1 static uio_FileSystemInfo * -uio_newFileSystemInfo(uio_FileSystemID id, uio_FileSystemHandler *handler, +uio_FileSystemInfo_new(uio_FileSystemID id, uio_FileSystemHandler *handler, char *name) { uio_FileSystemInfo *result; - result = uio_allocFileSystemInfo(); + result = uio_FileSystemInfo_alloc(); result->id = id; result->handler = handler; result->name = name; @@ -249,7 +249,7 @@ uio_newFileSystemInfo(uio_FileSystemID id, uio_FileSystemHandler *handler, // *** Allocators *** static inline uio_FileSystemInfo * -uio_allocFileSystemInfo(void) { +uio_FileSystemInfo_alloc(void) { uio_FileSystemInfo *result = uio_malloc(sizeof (uio_FileSystemInfo)); #ifdef uio_MEM_DEBUG uio_MemDebug_debugAlloc(uio_FileSystemInfo, (void *) result); diff --git a/sc2/src/sc2code/libs/uio/io.c b/sc2/src/sc2code/libs/uio/io.c index 70e6f029a..f4f12804a 100644 --- a/sc2/src/sc2code/libs/uio/io.c +++ b/sc2/src/sc2code/libs/uio/io.c @@ -89,7 +89,7 @@ uio_unInit(void) { uio_Repository * uio_openRepository(int flags) { - return uio_newRepository(flags); + return uio_Repository_new(flags); } void @@ -270,7 +270,7 @@ uio_mountDir(uio_Repository *destRep, const char *mountPoint, // InPath is a copy with the paths fixed. uio_free(unixPath); #endif - mountInfo = uio_newMountInfo(fsType, NULL, endDirHandle, dirName, + mountInfo = uio_MountInfo_new(fsType, NULL, endDirHandle, dirName, autoMount, NULL, flags); uio_repositoryAddMount(destRep, mountInfo, flags & uio_MOUNT_LOCATION_MASK, relativeInfo); @@ -1015,11 +1015,11 @@ static uio_DirList *uio_getDirListMulti(uio_PDirHandle **pDirHandles, int numPDirHandles, const char *pattern, match_MatchType matchType); static uio_DirList *uio_makeDirList(const char **newNames, const char * const *names, int numNames); -static uio_DirList *uio_newDirList(const char **names, int numNames, +static uio_DirList *uio_DirList_new(const char **names, int numNames, char *buffer); static void uio_collectDirEntries(uio_PDirHandle *pDirHandle, uio_DirBufferLink **linkPtr, int *numEntries); -static inline uio_DirList *uio_allocDirList(void); +static inline uio_DirList *uio_DirList_alloc(void); static void uio_filterNames(const char * const *names, int numNames, const char **newNames, int *numNewNames, match_MatchContext *matchContext); @@ -1054,7 +1054,7 @@ uio_getDirList(uio_DirHandle *dirHandle, const char *path, const char *pattern, if (numPDirHandles == 0) { assert(pDirHandles == NULL); // nothing to free - return uio_newDirList(NULL, 0, NULL); + return uio_DirList_new(NULL, 0, NULL); } result = uio_getDirListMulti(pDirHandles, numPDirHandles, pattern, @@ -1210,7 +1210,7 @@ uio_makeDirList(const char **newNames, const char * const *names, totLen += numNames; // for the \0's - result = uio_newDirList(newNames, numNames, uio_malloc(totLen)); + result = uio_DirList_new(newNames, numNames, uio_malloc(totLen)); bufPtr = result->buffer; for (i = 0; i < numNames; i++) { @@ -1373,10 +1373,10 @@ uio_freeDirBufferChain(uio_DirBufferLink *dirBufferLink) { } static uio_DirList * -uio_newDirList(const char **names, int numNames, char *buffer) { +uio_DirList_new(const char **names, int numNames, char *buffer) { uio_DirList *result; - result = uio_allocDirList(); + result = uio_DirList_alloc(); result->names = names; result->numNames = numNames; result->buffer = buffer; @@ -1384,7 +1384,7 @@ uio_newDirList(const char **names, int numNames, char *buffer) { } static uio_DirList * -uio_allocDirList(void) { +uio_DirList_alloc(void) { return uio_malloc(sizeof (uio_DirList)); } diff --git a/sc2/src/sc2code/libs/uio/ioaux.c b/sc2/src/sc2code/libs/uio/ioaux.c index 8199e34cb..d6d6fac4d 100644 --- a/sc2/src/sc2code/libs/uio/ioaux.c +++ b/sc2/src/sc2code/libs/uio/ioaux.c @@ -37,7 +37,7 @@ static int copyError(int error, * Follow a path starting from a specified physical dir as long as possible. * When you can get no further, 'endPDirHandle' will be filled in with a * reference to the dir where you ended up, and 'pathRest' will point into - * the original path. to the beginning of the part that was not matched. + * the original path to the beginning of the part that was not matched. * It is allowed to have endPDirHandle point to pDirHandle and/or restPath * point to path when calling this function. Just take care to keep a * reference to the original so you can decrement the ref counter. @@ -725,7 +725,9 @@ uio_verifyPath(uio_DirHandle *dirHandle, const char *path, // Get the absolute path pointed to by 'path' relative to 'dirHandle' // The new path will be put in '*destPath', which will be newly allocated. -// It will be \0-terminated, and the length will be returned. +// It will be \0-terminated, and will not have a '/' as first or last +// character. +// The length of '*destPath' will be returned. // On error, -1 will be returned, and errno will be set. ssize_t uio_resolvePath(uio_DirHandle *dirHandle, const char *path, size_t pathLen, @@ -828,7 +830,7 @@ uio_resolvePath(uio_DirHandle *dirHandle, const char *path, size_t pathLen, endBufPtr--; *endBufPtr = '/'; } else { - // We're already done. Might as well take advantage of + // We're already done. We might as well take advantage of // the fact that we know that and exit immediatly: *destPath = buffer; return len; @@ -853,7 +855,7 @@ uio_resolvePath(uio_DirHandle *dirHandle, const char *path, size_t pathLen, endBufPtr--; *endBufPtr = '/'; } else { - // We're already done. Might as well take advantage of + // We're already done. We might as well take advantage of // the fact that we know that and exit immediatly: break; } diff --git a/sc2/src/sc2code/libs/uio/iointrn.h b/sc2/src/sc2code/libs/uio/iointrn.h index 2ada4ea65..141b449fa 100644 --- a/sc2/src/sc2code/libs/uio/iointrn.h +++ b/sc2/src/sc2code/libs/uio/iointrn.h @@ -53,7 +53,8 @@ struct uio_DirHandle { int ref; struct uio_Repository *repository; char *path; - // does not contain any '.' or '..' + // does not contain any '.' or '..'; does not start or end + // with a / char *rootEnd; // points to the end of the part of path that is considered // the root dir. (you can't use '..' to get above the root dir) diff --git a/sc2/src/sc2code/libs/uio/mount.c b/sc2/src/sc2code/libs/uio/mount.c index ac1d78f98..623106c6f 100644 --- a/sc2/src/sc2code/libs/uio/mount.c +++ b/sc2/src/sc2code/libs/uio/mount.c @@ -32,7 +32,7 @@ #endif static void uio_deleteRepository(uio_Repository *repository); -static uio_Repository *uio_allocRepository(void); +static uio_Repository *uio_Repository_alloc(void); static void uio_freeRepository(uio_Repository *repository); @@ -119,10 +119,10 @@ uio_repositoryRemoveMount(uio_Repository *repository, uio_MountInfo *mountInfo) // sets ref to 1 uio_Repository * -uio_newRepository(int flags) { +uio_Repository_new(int flags) { uio_Repository *result; - result = uio_allocRepository(); + result = uio_Repository_alloc(); result->ref = 1; result->flags = flags; result->numMounts = 0; @@ -141,7 +141,7 @@ uio_Repository_unref(uio_Repository *repository) { } static uio_Repository * -uio_allocRepository(void) { +uio_Repository_alloc(void) { uio_Repository *result = uio_malloc(sizeof (uio_Repository)); #ifdef uio_MEM_DEBUG uio_MemDebug_debugAlloc(uio_Repository, (void *) result); diff --git a/sc2/src/sc2code/libs/uio/mount.h b/sc2/src/sc2code/libs/uio/mount.h index f754529d3..90b638d64 100644 --- a/sc2/src/sc2code/libs/uio/mount.h +++ b/sc2/src/sc2code/libs/uio/mount.h @@ -49,7 +49,7 @@ struct uio_Repository { #define lockRepository(repository, prot) #define unlockRepository(repository) -uio_Repository *uio_newRepository(int flags); +uio_Repository *uio_Repository_new(int flags); void uio_Repository_unref(uio_Repository *repository); void uio_repositoryAddMount(uio_Repository *repository, uio_MountInfo *mountInfo, uio_MountLocation location, diff --git a/sc2/src/sc2code/libs/uio/mounttree.c b/sc2/src/sc2code/libs/uio/mounttree.c index fdef5a6f9..dc69ac33e 100644 --- a/sc2/src/sc2code/libs/uio/mounttree.c +++ b/sc2/src/sc2code/libs/uio/mounttree.c @@ -69,21 +69,21 @@ static uio_PathComp *uio_makePathComps(const char *path, uio_PathComp *upComp); static void uio_printMount(FILE *outStream, const uio_MountInfo *mountInfo); -static inline uio_MountTree * uio_newMountTree(uio_MountTree *subTrees, +static inline uio_MountTree * uio_MountTree_new(uio_MountTree *subTrees, uio_MountTreeItem *pLocs, uio_MountTree *upTree, uio_PathComp *comps, uio_PathComp *lastComp, uio_MountTree *next); -static inline uio_MountTreeItem *uio_newMountTreeItem( +static inline uio_MountTreeItem *uio_MountTree_newItem( uio_MountInfo *mountInfo, int depth, uio_MountTreeItem *next); -static inline uio_PathComp *uio_newPathComp(char *name, size_t nameLen, +static inline uio_PathComp *uio_PathComp_new(char *name, size_t nameLen, uio_PathComp *upComp); static inline void uio_deleteMountTreeItem(uio_MountTreeItem *item); static inline void uio_deletePathComp(uio_PathComp *pathComp); -static inline uio_MountTree *uio_allocMountTree(void); -static inline uio_MountTreeItem *uio_allocMountTreeItem(void); -static inline uio_MountInfo *uio_allocMountInfo(void); -static inline uio_PathComp *uio_allocPathComp(void); +static inline uio_MountTree *uio_MountTree_alloc(void); +static inline uio_MountTreeItem *uio_MountTreeItem_alloc(void); +static inline uio_MountInfo *uio_MountInfo_alloc(void); +static inline uio_PathComp *uio_PathComp_alloc(void); static inline void uio_freeMountTree(uio_MountTree *mountTree); static inline void uio_freeMountTreeItem(uio_MountTreeItem *mountTreeItem); @@ -94,7 +94,7 @@ static inline void uio_freePathComp(uio_PathComp *pathComp); // make the root mount Tree uio_MountTree * uio_makeRootMountTree(void) { - return uio_newMountTree(NULL, NULL, NULL, NULL, NULL, NULL); + return uio_MountTree_new(NULL, NULL, NULL, NULL, NULL, NULL); } // Add a MountInfo structure to a MountTree in the place pointed @@ -222,7 +222,7 @@ uio_mountTreeAddMountInfoLocAll(uio_Repository *repository, uio_MountTree *tree, int compCount; // Add a new PLoc to this mountTree - newPLoc = uio_newMountTreeItem(mountInfo, depth, NULL); + newPLoc = uio_MountTree_newItem(mountInfo, depth, NULL); uio_addMountTreeItem(repository, &tree->pLocs, newPLoc, location, relative); // Recurse for subtrees @@ -292,7 +292,7 @@ uio_copyMountTreeItems(uio_MountTreeItem *item, int extraDepth) { resPtr = &result; while (item != NULL) { - newItem = uio_newMountTreeItem( + newItem = uio_MountTree_newItem( item->mountInfo, item->depth + extraDepth, NULL); *resPtr = newItem; resPtr = &newItem->next; @@ -318,12 +318,12 @@ uio_mountTreeAddNewSubTree(uio_Repository *repository, uio_MountTree *tree, compList = uio_makePathComps(path, upComp); compCount = uio_countPathComps(compList); lastComp = uio_lastPathComp(compList); - item = uio_newMountTreeItem(mountInfo, 0, NULL); + item = uio_MountTree_newItem(mountInfo, 0, NULL); item->next = NULL; items = uio_copyMountTreeItems(tree->pLocs, compCount); uio_addMountTreeItem(repository, &items, item, location, relative); - newTree = uio_newMountTree( + newTree = uio_MountTree_new( NULL /* subTrees */, items /* pLocs */, tree /* upTree */, @@ -357,7 +357,7 @@ uio_splitMountTree(uio_MountTree **tree, uio_PathComp *lastComp, int depth) { uio_MountTreeItem *items; items = uio_copyMountTreeItems((*tree)->upTree->pLocs, depth); - newTree = uio_newMountTree( + newTree = uio_MountTree_new( *tree /* subTrees */, items /* pLocs */, (*tree)->upTree /* upTree */, @@ -535,7 +535,7 @@ uio_makePathComps(const char *path, uio_PathComp *upComp) { memcpy(str, start, end - start); str[end - start] = '\0'; - *compPtr = uio_newPathComp(str, end - start, upComp); + *compPtr = uio_PathComp_new(str, end - start, upComp); upComp = *compPtr; compPtr = &(*compPtr)->next; getNextPath0Component(&start, &end); @@ -741,12 +741,12 @@ uio_printMounts(FILE *outStream, const uio_Repository *repository) { // *** uio_MountTree*** // static inline uio_MountTree * -uio_newMountTree(uio_MountTree *subTrees, uio_MountTreeItem *pLocs, +uio_MountTree_new(uio_MountTree *subTrees, uio_MountTreeItem *pLocs, uio_MountTree *upTree, uio_PathComp *comps, uio_PathComp *lastComp, uio_MountTree *next) { uio_MountTree *result; - result = uio_allocMountTree(); + result = uio_MountTree_alloc(); result->subTrees = subTrees; result->pLocs = pLocs; result->upTree = upTree; @@ -782,7 +782,7 @@ uio_deleteMountTree(uio_MountTree *tree) { } static inline uio_MountTree * -uio_allocMountTree(void) { +uio_MountTree_alloc(void) { uio_MountTree *result = uio_malloc(sizeof (uio_MountTree)); #ifdef uio_MEM_DEBUG uio_MemDebug_debugAlloc(uio_MountTree, (void *) result); @@ -802,11 +802,11 @@ uio_freeMountTree(uio_MountTree *mountTree) { // *** uio_MountTreeItem *** // static inline uio_MountTreeItem * -uio_newMountTreeItem(uio_MountInfo *mountInfo, int depth, +uio_MountTree_newItem(uio_MountInfo *mountInfo, int depth, uio_MountTreeItem *next) { uio_MountTreeItem *result; - result = uio_allocMountTreeItem(); + result = uio_MountTreeItem_alloc(); result->mountInfo = mountInfo; result->depth = depth; result->next = next; @@ -819,7 +819,7 @@ uio_deleteMountTreeItem(uio_MountTreeItem *item) { } static inline uio_MountTreeItem * -uio_allocMountTreeItem(void) { +uio_MountTreeItem_alloc(void) { uio_MountTreeItem *result = uio_malloc(sizeof (uio_MountTreeItem)); #ifdef uio_MEM_DEBUG uio_MemDebug_debugAlloc(uio_MountTreeItem, (void *) result); @@ -839,12 +839,12 @@ uio_freeMountTreeItem(uio_MountTreeItem *mountTreeItem) { // *** uio_MountInfo *** // uio_MountInfo * -uio_newMountInfo(uio_FileSystemID fsID, uio_MountTree *mountTree, +uio_MountInfo_new(uio_FileSystemID fsID, uio_MountTree *mountTree, uio_PDirHandle *pDirHandle, char *dirName, uio_AutoMount **autoMount, uio_MountHandle *mountHandle, int flags) { uio_MountInfo *result; - result = uio_allocMountInfo(); + result = uio_MountInfo_alloc(); result->fsID = fsID; result->mountTree = mountTree; result->pDirHandle = pDirHandle; @@ -863,7 +863,7 @@ uio_deleteMountInfo(uio_MountInfo *mountInfo) { } static inline uio_MountInfo * -uio_allocMountInfo(void) { +uio_MountInfo_alloc(void) { uio_MountInfo *result = uio_malloc(sizeof (uio_MountInfo)); #ifdef uio_MEM_DEBUG uio_MemDebug_debugAlloc(uio_MountInfo, (void *) result); @@ -886,10 +886,10 @@ uio_freeMountInfo(uio_MountInfo *mountInfo) { // no copy is made. // 'namelen' should be the length of 'name' static inline uio_PathComp * -uio_newPathComp(char *name, size_t nameLen, uio_PathComp *upComp) { +uio_PathComp_new(char *name, size_t nameLen, uio_PathComp *upComp) { uio_PathComp *result; - result = uio_allocPathComp(); + result = uio_PathComp_alloc(); result->name = name; result->nameLen = nameLen; result->up = upComp; @@ -909,7 +909,7 @@ uio_deletePathComp(uio_PathComp *pathComp) { } static inline uio_PathComp * -uio_allocPathComp(void) { +uio_PathComp_alloc(void) { uio_PathComp *result = uio_malloc(sizeof (uio_PathComp)); #ifdef uio_MEM_DEBUG uio_MemDebug_debugAlloc(uio_PathComp, (void *) result); diff --git a/sc2/src/sc2code/libs/uio/mounttree.h b/sc2/src/sc2code/libs/uio/mounttree.h index 3b045f35c..f2c2eaf18 100644 --- a/sc2/src/sc2code/libs/uio/mounttree.h +++ b/sc2/src/sc2code/libs/uio/mounttree.h @@ -194,8 +194,9 @@ void uio_findMountTree(uio_MountTree *top, const char *path, char *uio_mountTreeItemRestPath(const uio_MountTreeItem *item, uio_PathComp *endComp, const char *path); int uio_mountTreeCountPLocs(const uio_MountTree *tree); -uio_MountInfo *uio_newMountInfo(uio_FileSystemID fsID, uio_MountTree *mountTree, - uio_PDirHandle *pDirHandle, char *dirName, uio_AutoMount **autoMount, +uio_MountInfo *uio_MountInfo_new(uio_FileSystemID fsID, + uio_MountTree *mountTree, uio_PDirHandle *pDirHandle, + char *dirName, uio_AutoMount **autoMount, uio_MountHandle *mountHandle, int flags); void uio_deleteMountInfo(uio_MountInfo *mountInfo); void uio_printMountTree(FILE *outStream, const uio_MountTree *tree, int indent); diff --git a/sc2/src/sc2code/libs/uio/paths.c b/sc2/src/sc2code/libs/uio/paths.c index 095079b9c..c053dedaa 100644 --- a/sc2/src/sc2code/libs/uio/paths.c +++ b/sc2/src/sc2code/libs/uio/paths.c @@ -174,7 +174,7 @@ joinPaths(const char *first, const char *second) { return result; } -// Combine two parts of a paths into a new path, +// Combine two parts of a paths into a new path. // The new path will always start with a '/'. // The first path may (but doesn't have to) end on a '/', or may be empty. // Pre: the second path doesn't start with a '/' @@ -215,6 +215,11 @@ joinPathsAbsolute(const char *first, const char *second) { return result; } +// Returns 'false' if +// - one of the path components is empty, or +// - one of the path components is ".", or +// - one of the path components is ".." +// and 'true' otherwise. uio_bool validPathName(const char *path, size_t len) { const char *pathEnd;