Skip to content

Commit b1a4199

Browse files
committed
libutil/fname,comment: add description for canonicalizeFileName
1 parent 09d1455 commit b1a4199

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

main/fname.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,23 @@ struct canonFnameCacheTable;
1515
extern struct canonFnameCacheTable *canonFnameCacheTableNew (const char *cwd);
1616
extern void canonFnameCacheTableDelete (struct canonFnameCacheTable *cache_table);
1717

18-
/* Don't free the cstring returned from this function directly.
19-
* This function stores the cstring to the cache.
18+
/*
19+
* If INPUT is an absolute path (starting form '/'), return new absolute path
20+
* string after resolving '..', '.', and '//' in it. '//' is reduced to '/'.
21+
*
22+
* If INPUT is a relative path, resolve '.', '..', and '//' as if the current
23+
* working directly is the CWD passed canonFnameCacheTableNew(). The return
24+
* string may absolute or relative path form.
25+
*
26+
* In most of all cases, the string return from this function doesn't
27+
* include ".". There is one exception.
28+
* If the resolved file name is the same as CWD canonFnameCacheTableNew(),
29+
* this function returns just ".".
30+
*
31+
* Don't free the cstring returned from this function directly.
32+
* This function stores the cstring to the CACHE_TABLE for processing the
33+
* same INPUT more than twice. canonFnameCacheTableDelete() destroys all C
34+
* strings returned from this function.
2035
*/
2136
extern const char *canonicalizeRelativeFileName(struct canonFnameCacheTable *cache_table,
2237
const char *input);

0 commit comments

Comments
 (0)