153
*-----------------------------------------------------------------------------
155
* File_GetFilePermissions --
157
* Return the read / write / execute permissions of a file.
160
* TRUE if success, FALSE otherwise.
165
*-----------------------------------------------------------------------------
169
File_GetFilePermissions(ConstUnicode pathName, // IN:
170
int *mode) // OUT: file mode
175
if (FileAttributes(pathName, &fileData) != 0) {
178
*mode = fileData.fileMode;
181
* On Win32 implementation of FileAttributes does not return execution bit.
183
if (FileIO_Access(pathName, FILEIO_ACCESS_EXEC) == FILEIO_SUCCESS) {
152
192
*----------------------------------------------------------------------
1718
*-----------------------------------------------------------------------------
1720
* File_MapPathPrefix --
1722
* Given a path and a newPrefix -> oldPrefix mapping, transform
1723
* oldPath according to the mapping.
1726
* The new path, or NULL if there is no mapping.
1729
* The returned string is allocated, free it.
1731
*-----------------------------------------------------------------------------
1735
File_MapPathPrefix(const char *oldPath, // IN
1736
const char **oldPrefixes, // IN
1737
const char **newPrefixes, // IN
1738
size_t numPrefixes) // IN
1741
size_t oldPathLen = strlen(oldPath);
1743
for (i = 0; i < numPrefixes; i++) {
1747
size_t oldPrefixLen;
1749
oldPrefix = File_StripSlashes(oldPrefixes[i]);
1750
newPrefix = File_StripSlashes(newPrefixes[i]);
1751
oldPrefixLen = strlen(oldPrefix);
1754
* If the prefix matches on a DIRSEPS boundary, or the prefix is the
1755
* whole string, replace it.
1756
* If we don't insist on matching a whole directory name, we could
1757
* mess things of if one directory is a substring of another.
1760
if (oldPathLen >= oldPrefixLen &&
1761
memcmp(oldPath, oldPrefix, oldPrefixLen) == 0
1762
&& (strchr(VALID_DIRSEPS, oldPath[oldPrefixLen]) ||
1763
oldPath[oldPrefixLen] == '\0')) {
1764
size_t newPrefixLen = strlen(newPrefix);
1765
size_t newPathLen = (oldPathLen - oldPrefixLen) + newPrefixLen;
1767
ASSERT(newPathLen > 0);
1768
ASSERT(oldPathLen >= oldPrefixLen);
1770
newPath = Util_SafeMalloc((newPathLen + 1) * sizeof(char));
1771
memcpy(newPath, newPrefix, newPrefixLen);
1772
memcpy(newPath + newPrefixLen, oldPath + oldPrefixLen,
1773
oldPathLen - oldPrefixLen + 1);
1775
* It should only match once. Weird self-referencing mappings
1677
1790
#if !defined(N_PLAT_NLM)
1679
1792
*----------------------------------------------------------------------------