#include "hostinfo.h"
#include "hostType.h"
#include "vm_atomic.h"
+#include "fileLock.h"
#include "unicodeOperations.h"
Bool
File_Exists(ConstUnicode pathName) // IN: May be NULL.
{
+ if (pathName == NULL) {
+ Log("%s: NULL pathName\n", __FUNCTION__);
+ } else {
+ FileLock_IsLocked(pathName, NULL, NULL);
+ }
+
return FileIO_IsSuccess(FileIO_Access(pathName, FILEIO_ACCESS_EXISTS));
}
int
File_UnlinkIfExists(ConstUnicode pathName) // IN:
{
- int ret;
-
- ret = FileDeletion(pathName, TRUE);
+ int ret = FileDeletion(pathName, TRUE);
if (ret != 0) {
ret = (ret == ENOENT) ? 0 : -1;
numEntries = FileListDirectoryRobust(lockDir, &fileList);
- if (numEntries == -1 && errno != ENOENT) {
+ if (numEntries == -1) {
/*
* If the lock directory doesn't exist, we should not count this
* as an error. This is expected if the file isn't locked.
*/
if (err != NULL) {
- *err = errno;
+ *err = (errno == ENOENT) ? 0 : errno;
}
return FALSE;
for (i = 0; i < numEntries; i++) {
Unicode_Free(fileList[i]);
}
+
free(fileList);
return isLocked;
FileLockIsLocked(ConstUnicode pathName, // IN:
int *err) // OUT/OPT:
{
- Unicode lockBase = Unicode_Append(pathName, FILELOCK_SUFFIX);
Bool isLocked;
+ Unicode lockBase;
+
+ ASSERT(pathName);
+
+ lockBase = Unicode_Append(pathName, FILELOCK_SUFFIX);
if (File_SupportsMandatoryLock(pathName)) {
isLocked = FileLockIsLockedMandatory(lockBase, err);