mirror of
https://github.com/cc65/cc65.git
synced 2024-06-18 07:29:36 +00:00
Move FindAbsolutePath to another .c
This commit is contained in:
parent
7798c7a471
commit
acf9676c0f
|
@ -37,9 +37,6 @@
|
|||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
#endif
|
||||
|
||||
/* common */
|
||||
#include "chartype.h"
|
||||
|
@ -49,6 +46,7 @@
|
|||
#include "xmalloc.h"
|
||||
#include "strpool.h"
|
||||
#include "abend.h"
|
||||
#include "pathutil.h"
|
||||
|
||||
/* cc65 */
|
||||
#include "codegen.h"
|
||||
|
@ -2970,31 +2968,6 @@ static void DoLine (void)
|
|||
MLine = InitLine (MLine);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the absolute path of the given relative path.
|
||||
* The absolute path for the file is stored in a malloced buffer.
|
||||
* Returns NULL if some error occured.
|
||||
*/
|
||||
char *FindAbsolutePath (const char *path);
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
char *FindAbsolutePath (const char *path) {
|
||||
return _fullpath (NULL, path, MAX_PATH);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
extern char* realpath (const char* path, char* resolved_path);
|
||||
|
||||
/* this uses the POSIX1.-2008 version of the function,
|
||||
which solves the problem of finding a maximum path length for the file */
|
||||
char* FindAbsolutePath (const char* path) {
|
||||
return realpath (path, NULL);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* Possible outcomes of preprocessing a pragma */
|
||||
typedef enum {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
|
@ -110,6 +110,7 @@
|
|||
<ClInclude Include="common\objdefs.h" />
|
||||
<ClInclude Include="common\optdefs.h" />
|
||||
<ClInclude Include="common\print.h" />
|
||||
<ClInclude Include="common\pathutil.h" />
|
||||
<ClInclude Include="common\scopedefs.h" />
|
||||
<ClInclude Include="common\searchpath.h" />
|
||||
<ClInclude Include="common\segdefs.h" />
|
||||
|
@ -155,6 +156,7 @@
|
|||
<ClCompile Include="common\matchpat.c" />
|
||||
<ClCompile Include="common\mmodel.c" />
|
||||
<ClCompile Include="common\print.c" />
|
||||
<ClCompile Include="common\pathutil.c" />
|
||||
<ClCompile Include="common\searchpath.c" />
|
||||
<ClCompile Include="common\segnames.c" />
|
||||
<ClCompile Include="common\shift.c" />
|
||||
|
@ -171,4 +173,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
25
src/common/pathutil.c
Normal file
25
src/common/pathutil.c
Normal file
|
@ -0,0 +1,25 @@
|
|||
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
#if defined(_WIN32)
|
||||
# include <windows.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
|
||||
char *FindAbsolutePath (const char *path) {
|
||||
return _fullpath (NULL, path, MAX_PATH);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
extern char* realpath (const char* path, char* resolved_path);
|
||||
|
||||
/* this uses the POSIX1.-2008 version of the function,
|
||||
which solves the problem of finding a maximum path length for the file */
|
||||
char* FindAbsolutePath (const char* path) {
|
||||
return realpath (path, NULL);
|
||||
}
|
||||
|
||||
#endif
|
56
src/common/pathutil.h
Normal file
56
src/common/pathutil.h
Normal file
|
@ -0,0 +1,56 @@
|
|||
/*****************************************************************************/
|
||||
/* */
|
||||
/* pathutil.h */
|
||||
/* Path manipulation utilities */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* (C) 2003-2008 Ullrich von Bassewitz */
|
||||
/* Roemerstrasse 52 */
|
||||
/* D-70794 Filderstadt */
|
||||
/* EMail: uz@cc65.org */
|
||||
/* */
|
||||
/* */
|
||||
/* This software is provided 'as-is', without any expressed or implied */
|
||||
/* warranty. In no event will the authors be held liable for any damages */
|
||||
/* arising from the use of this software. */
|
||||
/* */
|
||||
/* Permission is granted to anyone to use this software for any purpose, */
|
||||
/* including commercial applications, and to alter it and redistribute it */
|
||||
/* freely, subject to the following restrictions: */
|
||||
/* */
|
||||
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||
/* claim that you wrote the original software. If you use this software */
|
||||
/* in a product, an acknowledgment in the product documentation would be */
|
||||
/* appreciated but is not required. */
|
||||
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||
/* be misrepresented as being the original software. */
|
||||
/* 3. This notice may not be removed or altered from any source */
|
||||
/* distribution. */
|
||||
/* */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
|
||||
#ifndef PATHUTIL_H
|
||||
#define PATHUTIL_H
|
||||
|
||||
|
||||
/*****************************************************************************/
|
||||
/* Code */
|
||||
/*****************************************************************************/
|
||||
|
||||
|
||||
/**
|
||||
* Determines the absolute path of the given relative path.
|
||||
* 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.
|
||||
*/
|
||||
char *FindAbsolutePath (const char *path);
|
||||
|
||||
|
||||
|
||||
/* End of pathutil.h */
|
||||
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user