mirror of
https://github.com/cc65/cc65.git
synced 2024-06-08 15:29:37 +00:00
Improve pathutil.c style
This commit is contained in:
parent
57e6c2a4f9
commit
6e203ab2d2
|
@ -11,17 +11,17 @@
|
|||
|
||||
char *FindRealPath (const char *Path)
|
||||
/*
|
||||
** Determines the real path the given relative path of an existing file.
|
||||
** If the path points to a symlink, resolves such symlink.
|
||||
** The real path for the file is stored in a malloced buffer.
|
||||
** Returns NULL if the file doesn't exist.
|
||||
** The returned path's separator is system specific.
|
||||
** Returns a malloced buffer containing the canonical path of the given path.
|
||||
** If the path points to a non-existent file, or if any error occurs, NULL is returned.
|
||||
** If the path points to a symlink, the resolved symlink path is returned.
|
||||
** Note: The returned path's separator is system specific.
|
||||
*/
|
||||
{
|
||||
|
||||
HANDLE Handle = CreateFileA (Path,
|
||||
FILE_READ_ATTRIBUTES,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
FILE_SHARE_READ |
|
||||
FILE_SHARE_WRITE | FILE_SHARE_DELETE,
|
||||
NULL,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_BACKUP_SEMANTICS,
|
||||
|
@ -32,20 +32,21 @@ char *FindRealPath (const char *Path)
|
|||
}
|
||||
|
||||
size_t BufferSize = MAX_PATH + 10;
|
||||
char* Buffer = xmalloc(BufferSize);
|
||||
char* Buffer = xmalloc (BufferSize);
|
||||
|
||||
DWORD Status = GetFinalPathNameByHandleA (Handle,
|
||||
Buffer,
|
||||
BufferSize,
|
||||
FILE_NAME_NORMALIZED | VOLUME_NAME_DOS);
|
||||
FILE_NAME_NORMALIZED
|
||||
| VOLUME_NAME_DOS);
|
||||
|
||||
if (Status == 0) {
|
||||
free(Buffer);
|
||||
CloseHandle(Handle);
|
||||
xfree (Buffer);
|
||||
CloseHandle (Handle);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CloseHandle(Handle);
|
||||
CloseHandle (Handle);
|
||||
|
||||
return Buffer;
|
||||
}
|
||||
|
@ -56,11 +57,10 @@ extern char* realpath (const char* path, char* resolved_path);
|
|||
|
||||
char* FindRealPath (const char* path)
|
||||
/*
|
||||
** Determines the absolute path of the given relative path.
|
||||
** If the path points to a symlink, resolves such symlink.
|
||||
** The absolute path for the file is stored in a malloced buffer.
|
||||
** Returns NULL if some error occured.
|
||||
** The returned path's separator is system specific.
|
||||
** Returns a malloced buffer containing the canonical path of the given path.
|
||||
** If the path points to a non-existent file, or if any error occurs, NULL is returned.
|
||||
** If the path points to a symlink, the resolved symlink path is returned.
|
||||
** Note: The returned path's separator is system specific.
|
||||
*/
|
||||
{
|
||||
return realpath (path, NULL);
|
||||
|
|
|
@ -43,11 +43,10 @@
|
|||
|
||||
char *FindRealPath (const char *path);
|
||||
/*
|
||||
** Determines the real path the given relative path of an existing file.
|
||||
** If the path points to a symlink, resolves such symlink.
|
||||
** The real path for the file is stored in a malloced buffer.
|
||||
** Returns NULL if the file doesn't exist.
|
||||
** The returned path's separator is system specific.
|
||||
** Returns a malloced buffer containing the canonical path of the given path.
|
||||
** If the path points to a non-existent file, or if any error occurs, NULL is returned.
|
||||
** If the path points to a symlink, the resolved symlink path is returned.
|
||||
** Note: The returned path's separator is system specific.
|
||||
*/
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user