Bool
File_CreateDirectoryEx(const char *pathName, // IN:
- int mask) // IN:
+ int mode) // IN:
{
- int err = FileCreateDirectory(pathName, mask);
+ int err = FileCreateDirectory(pathName, mode);
return err == 0;
}
* Results:
* TRUE Directory was created
* FALSE Directory creation failed.
- * See File_EnsureDirectoryEx for dealing with directories that
+ * See File_EnsureDirectory for dealing with directories that
* may exist.
*
* Side effects:
Bool
File_EnsureDirectoryEx(const char *pathName, // IN:
- int mask) // IN:
+ int mode) // IN:
{
- int err = FileCreateDirectory(pathName, mask);
+ int err = FileCreateDirectory(pathName, mode);
+
+ if (err == EEXIST) {
+ FileData fileData;
+
+ err = FileAttributes(pathName, &fileData);
+
+ if (err == 0) {
+ if (fileData.fileType != FILE_TYPE_DIRECTORY) {
+ err = ENOTDIR;
+ errno = ENOTDIR;
+
+#if defined(_WIN32)
+ SetLastError(ERROR_DIRECTORY);
+#endif
+ }
+ }
+ }
- return ((err == 0) || (err == EEXIST));
+ return err == 0;
}
Bool
File_CreateDirectoryHierarchyEx(const char *pathName, // IN:
- int mask, // IN:
+ int mode, // IN:
char **topmostCreated) // OUT/OPT:
{
char *volume;
* confusing. We avoid this by attempting to create the directory before
* checking the type.
*/
- err = FileCreateDirectory(temp, mask);
+ err = FileCreateDirectory(temp, mode);
if (err == 0) {
if (topmostCreated != NULL && *topmostCreated == NULL) {
/*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
Bool File_CreateDirectory(const char *pathName);
Bool File_CreateDirectoryEx(const char *pathName,
- int mask);
+ int mode);
Bool File_EnsureDirectory(const char *pathName);
+Bool File_EnsureDirectoryEx(const char *pathName,
+ int mode);
+
Bool File_DeleteEmptyDirectory(const char *pathName);
Bool File_CreateDirectoryHierarchy(const char *pathName,
char **topmostCreated);
Bool File_CreateDirectoryHierarchyEx(const char *pathName,
- int mask,
+ int mode,
char **topmostCreated);
Bool File_DeleteDirectoryContent(const char *pathName);