* uses the effective uid, but it's too risky to fix right now.
* See PR 459242.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* TRUE file is accessible with the process' real uid
* FALSE file doesn't exist or an error occured
*
* If the given file exists, unlink it.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* Return 0 if the unlink is successful or if the file did not exist.
* Otherwise return -1.
*
* Check if specified file is a directory or not.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* TRUE is a directory
* FALSE is not a directory or an error occured
*
* Return the read / write / execute permissions of a file.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* TRUE if success, FALSE otherwise.
*
* followed.
* WINDOWS: No symbolic links so no link following.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* Return 0 if the unlink is successful. Otherwise, returns -1.
*
* On Windows, there are no symbolic links so this is the same as
* File_Unlink
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* Return 0 if the unlink is successful. Otherwise, returns -1.
*
}
-/*
- *----------------------------------------------------------------------
- *
- * FileCreateDirectoryEx --
- *
- * Creates the specified directory with the specified permissions.
- *
- * Results:
- * True if the directory is successfully created, false otherwise.
- *
- * Side effects:
- * Creates the directory on disk.
- *
- *----------------------------------------------------------------------
- */
-
-static int
-FileCreateDirectoryEx(const char *pathName, // IN:
- int mask) // IN:
-{
- int err = FileCreateDirectory(pathName, mask);
-
- if (err != 0) {
- Log(LGPFX" %s: Failed to create %s. Error = %d\n",
- __FUNCTION__, pathName, err);
- }
-
- return err;
-}
-
-
/*
*----------------------------------------------------------------------
*
*
* Creates the specified directory with the specified permissions.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
- * True if the directory is successfully created, false otherwise.
+ * TRUE Directory was created
+ * FALSE Directory creation failed.
+ * See File_EnsureDirectoryEx for dealing with directories that
+ * may exist.
*
* Side effects:
* Creates the directory on disk.
File_CreateDirectoryEx(const char *pathName, // IN:
int mask) // IN:
{
- int err = FileCreateDirectoryEx(pathName, mask);
+ int err = FileCreateDirectory(pathName, mask);
return err == 0;
}
*
* Creates the specified directory with 0777 permissions.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
- * True if the directory is successfully created, false otherwise.
+ * TRUE Directory was created
+ * FALSE Directory creation failed.
+ * See File_EnsureDirectoryEx for dealing with directories that
+ * may exist.
*
* Side effects:
* Creates the directory on disk.
Bool
File_CreateDirectory(const char *pathName) // IN:
{
- return File_CreateDirectoryEx(pathName, 0777);
+ int err = FileCreateDirectory(pathName, 0777);
+
+ return err == 0;
}
* If the directory doesn't exist, creates it. If the directory
* already exists, do nothing and succeed.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* See above.
*
int mask) // IN:
{
int err = FileCreateDirectory(pathName, mask);
- Bool success = ((err == 0) || (err == EEXIST));
-
- if (!success) {
- Log(LGPFX" %s: Failed to create %s. Error = %d\n",
- __FUNCTION__, pathName, err);
- }
- return success;
+ return ((err == 0) || (err == EEXIST));
}
* If the directory doesn't exist, creates it. If the directory
* already exists, do nothing and succeed.
*
+ * Errno/GetLastError is available upon failure.
+ *
* Results:
* See above.
*
/*
* If we check if the directory already exists and then we create it,
- * there is a race between these two operations - that might cause this
- * operation to fail with no reason.
- * This is why we reverse the attempt and the check.
+ * there is a race between these two operations. Any failure can be
+ * confusing. We avoid this by attempting to create the directory before
+ * checking the type.
*/
- err = FileCreateDirectoryEx(temp, mask);
+ err = FileCreateDirectory(temp, mask);
if (err == 0) {
if (topmostCreated != NULL && *topmostCreated == NULL) {
}
}
+ if (err != 0) {
+ Log(LGPFX" %s: Failure on '%s'. Error = %d\n",
+ __FUNCTION__, temp, err);
+ }
+
Posix_Free(temp);
if (err != 0) {