72 LPTSTR ppszFilePart=NULL;
75 nameLength = strlen(name);
78 if (nameLength < 1 || nameLength > MAX_PATH)
83 errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
84 if (GetFullPathName(name, MAX_PATH, (LPTSTR)fullName, &ppszFilePart))
88 if (-1 != (dwFileAttrib=GetFileAttributes((LPTSTR)fullName)) && (dwFileAttrib != FILE_ATTRIBUTE_DIRECTORY))
91 SetErrorMode(errorMode);
96 if (
SearchPath(NULL, (LPCTSTR)name, NULL, MAX_PATH, (LPTSTR)fullName, &ppszFilePart) )
99 if (-1 != (dwFileAttrib=GetFileAttributes((LPTSTR)fullName)) && (dwFileAttrib != FILE_ATTRIBUTE_DIRECTORY))
102 SetErrorMode(errorMode);
107 SetErrorMode(errorMode);
133 LPTSTR lpszLastNamePart;
137 if (qualifiedName[0] !=
'\0')
144 size_t len = strlen(unqualifiedName);
145 if ( len >= bufferSize)
147 qualifiedName[0] =
'\0';
152 strcpy(qualifiedName, unqualifiedName);
155 len = strlen(qualifiedName);
157 if (qualifiedName[len - 1] ==
':')
162 strcat(qualifiedName,
"\\");
167 qualifiedName[len - 1] =
'\0';
173 errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
174 DWORD rc = GetFullPathName(qualifiedName, (DWORD)bufferSize, qualifiedName, &lpszLastNamePart);
175 SetErrorMode(errorMode);
189 WIN32_FIND_DATA FindData;
192 errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
193 FindHandle = FindFirstFile(name, &FindData);
194 SetErrorMode(errorMode);
196 if (FindHandle != INVALID_HANDLE_VALUE)
198 FindClose(FindHandle);
199 if ((FindData.dwFileAttributes & FILE_ATTRIBUTE_SYSTEM)
200 || (FindData.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
201 || (FindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY))
225 DWORD dwAttrib = GetFileAttributes(name);
227 return (dwAttrib != INVALID_FILE_ATTRIBUTES &&
228 !((dwAttrib & FILE_ATTRIBUTE_SYSTEM)
229 || (dwAttrib & FILE_ATTRIBUTE_HIDDEN)
230 || (dwAttrib & FILE_ATTRIBUTE_DIRECTORY)));
247 const char *endPtr = pathName + file->
getLength() - 1;
251 while (pathName < endPtr)
258 return new_string(pathName, endPtr - pathName + 1);
279 const char *endPtr = pathName + file->
getLength() - 1;
283 while (pathName < endPtr)
291 else if (*endPtr ==
'.')
315 const char *endPtr = pathName + file->
getLength() - 1;
319 while (pathName < endPtr)
344 const char *endPtr = name + strlen(name) - 1;
348 while (name < endPtr)
356 else if (*endPtr ==
'.')
405 char tempName[MAX_PATH + 2];
408 strncpy(tempName, name,
sizeof(tempName));
409 if (extension != NULL)
411 strncat(tempName, extension,
sizeof(tempName) - strlen(tempName) - 1);
414 *resolvedName =
'\0';
424 if (
searchPath(name, path, extension, resolvedName))
445 return name[0] ==
'\\' || name[0] ==
'.' || name[2] ==
':';
461 size_t nameLength = strlen(name);
464 if (nameLength < 1 || nameLength > MAX_PATH)
470 unsigned int errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
471 LPTSTR ppszFilePart=NULL;
473 if (GetFullPathName(name, MAX_PATH, (LPTSTR)resolvedName, &ppszFilePart))
475 DWORD fileAttrib = GetFileAttributes((LPTSTR)resolvedName);
479 if (fileAttrib != INVALID_FILE_ATTRIBUTES && fileAttrib != FILE_ATTRIBUTE_DIRECTORY)
482 SetErrorMode(errorMode);
504 unsigned int errorMode = SetErrorMode(SEM_FAILCRITICALERRORS);
506 LPTSTR ppszFilePart=NULL;
507 if (
SearchPath((LPCTSTR)path, (LPCTSTR)name, (LPCTSTR)extension, MAX_PATH, (LPTSTR)resolvedName, &ppszFilePart))
509 DWORD fileAttrib = GetFileAttributes((LPTSTR)resolvedName);
513 if (fileAttrib != INVALID_FILE_ATTRIBUTES && fileAttrib != FILE_ATTRIBUTE_DIRECTORY)
516 SetErrorMode(errorMode);
535 if (size >= MAX_PATH)
537 DWORD length = GetLongPathName(fullName, fullName, (DWORD)size);
539 if ( 0 < length && length <= size )
541 WIN32_FIND_DATA findData;
542 HANDLE hFind = FindFirstFile(fullName, &findData);
543 if ( hFind != INVALID_HANDLE_VALUE )
545 p = strrchr(fullName,
'\\');
548 strcpy(++p, findData . cFileName);
567 return DeleteFile(name) != 0;
579 return RemoveDirectory(name) != 0;
593 DWORD dwAttrs = GetFileAttributes(name);
594 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_DIRECTORY);
607 DWORD dwAttrs = GetFileAttributes(name);
608 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_READONLY);
623 HANDLE handle = CreateFile(name, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
624 if (handle == INVALID_HANDLE_VALUE)
645 DWORD dwAttrs = GetFileAttributes(name);
646 return (dwAttrs != 0xffffffff) && (dwAttrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_REPARSE_POINT)) == 0;
659 DWORD dwAttrs = GetFileAttributes(name);
660 return (dwAttrs != 0xffffffff);
674 HANDLE newHandle = CreateFile(name, FILE_READ_ATTRIBUTES, FILE_SHARE_READ,
675 NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
676 if (newHandle == INVALID_HANDLE_VALUE)
681 FILETIME lastWriteTime;
682 if (!GetFileTime(newHandle, NULL, NULL, &lastWriteTime))
684 CloseHandle(newHandle);
692 int64_t result = (tempResult - 116444736000000000) / 10000000;
694 CloseHandle(newHandle);
708 WIN32_FILE_ATTRIBUTE_DATA stat;
710 if (GetFileAttributesEx(name, GetFileExInfoStandard, &stat) == 0)
716 result += (
int64_t)stat.nFileSizeLow;
730 return CreateDirectory(name, 0) != 0;
744 return MoveFile(oldName, newName) != 0;
757 DWORD dwAttrs = GetFileAttributes(name);
758 return (dwAttrs != 0xffffffff) && (dwAttrs & FILE_ATTRIBUTE_HIDDEN);
778 DWORD flags = FILE_ATTRIBUTE_NORMAL;
779 int result = GetFileAttributes(name);
780 if (result == 0xFFFFFFFF)
785 if (result & FILE_ATTRIBUTE_DIRECTORY)
787 flags = FILE_FLAG_BACKUP_SEMANTICS;
790 HANDLE hFile = CreateFile (name, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE,
791 NULL, OPEN_EXISTING, flags, NULL);
792 if (hFile == INVALID_HANDLE_VALUE)
800 fileTime.dwHighDateTime = (DWORD)(temp >> 32);
801 fileTime.dwLowDateTime = (DWORD)temp;
802 result = SetFileTime (hFile, (LPFILETIME)NULL, (LPFILETIME)NULL, &fileTime);
817 DWORD attrs = GetFileAttributes(name);
818 if (attrs == 0xFFFFFFFF)
823 attrs = attrs | FILE_ATTRIBUTE_READONLY;
824 return SetFileAttributes(name, attrs) != 0;
847 int length = GetLogicalDriveStrings(MAX_PATH, roots);
883 char pattern[MAX_PATH + 1];
887 strncpy(pattern, p,
sizeof(pattern));
888 strncat(pattern,
"\\*",
sizeof(pattern) - strlen(pattern) - 1);
894 if (
handle != INVALID_HANDLE_VALUE)
915 if (
handle != INVALID_HANDLE_VALUE)
918 handle = INVALID_HANDLE_VALUE;
RexxString * new_string(const char *s, stringsize_t l)
const char * getStringData()
WIN32_FIND_DATA findFileData
SysFileIterator(const char *pattern)
static bool fileExists(const char *name)
static bool checkCurrentFile(const char *name, char *resolvedName)
static bool moveFile(const char *oldName, const char *newName)
static bool setLastModifiedDate(const char *name, int64_t time)
static void getLongName(char *fullName, size_t size)
static const char * getSeparator()
static bool deleteFile(const char *name)
static bool deleteDirectory(const char *name)
static RexxString * extractFile(RexxString *file)
static bool setFileReadOnly(const char *name)
static const char * EOL_Marker
static bool hasDirectory(const char *name)
static const char * getTempFileName()
static int64_t getLastModifiedDate(const char *name)
static const char * getPathSeparator()
static int getRoots(char *roots)
static bool primitiveSearchName(const char *name, const char *path, const char *extension, char *resolvedName)
static bool searchName(const char *name, const char *path, const char *extension, char *resolvedName)
static bool makeDirectory(const char *name)
static RexxString * extractDirectory(RexxString *file)
static RexxString * extractExtension(RexxString *file)
static const char PathDelimiter
static bool isDirectory(const char *name)
static bool searchPath(const char *name, const char *path, char *resolvedName)
static bool isCaseSensitive()
static uint64_t getFileLength(const char *name)
static bool isWriteOnly(const char *name)
static void qualifyStreamName(const char *unqualifiedName, char *qualifiedName, size_t bufferSize)
static bool hasExtension(const char *name)
static const char EOF_Marker
static bool searchFileName(const char *name, char *fullName)
static bool findFirstFile(const char *name)
static bool isHidden(const char *name)
static bool isReadOnly(const char *name)
static bool exists(const char *name)
static bool isFile(const char *name)
int MoveFile(CSTRING fromFile, CSTRING toFile)
int SearchPath(int SearchFlag, const char *path, const char *filename, char *buf, size_t buf_size)