diff options
Diffstat (limited to 'source/core')
| -rw-r--r-- | source/core/core.vcxproj | 2 | ||||
| -rw-r--r-- | source/core/core.vcxproj.filters | 4 | ||||
| -rw-r--r-- | source/core/slang-io.cpp | 40 | ||||
| -rw-r--r-- | source/core/slang-io.h | 2 |
4 files changed, 43 insertions, 5 deletions
diff --git a/source/core/core.vcxproj b/source/core/core.vcxproj index 2d0c67342..d1ed4715f 100644 --- a/source/core/core.vcxproj +++ b/source/core/core.vcxproj @@ -213,7 +213,7 @@ <ClCompile Include="token-reader.cpp" /> </ItemGroup> <ItemGroup> - <None Include="core.natvis" /> + <Natvis Include="core.natvis" /> </ItemGroup> <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" /> <ImportGroup Label="ExtensionTargets"> diff --git a/source/core/core.vcxproj.filters b/source/core/core.vcxproj.filters index 1548217b4..7936ca11b 100644 --- a/source/core/core.vcxproj.filters +++ b/source/core/core.vcxproj.filters @@ -130,8 +130,8 @@ </ClCompile> </ItemGroup> <ItemGroup> - <None Include="core.natvis"> + <Natvis Include="core.natvis"> <Filter>Source Files</Filter> - </None> + </Natvis> </ItemGroup> </Project>
\ No newline at end of file diff --git a/source/core/slang-io.cpp b/source/core/slang-io.cpp index 24d5aa412..ab093f577 100644 --- a/source/core/slang-io.cpp +++ b/source/core/slang-io.cpp @@ -1,13 +1,20 @@ #include "slang-io.h" #include "exception.h" + #ifndef __STDC__ -#define __STDC__ 1 +# define __STDC__ 1 #endif + #include <sys/stat.h> + #ifdef _WIN32 -#include <direct.h> +# include <direct.h> #endif +#include <limits.h> /* PATH_MAX */ +#include <stdio.h> +#include <stdlib.h> + namespace Slang { bool File::Exists(const String & fileName) @@ -125,6 +132,32 @@ namespace Slang #endif } + /* static */SlangResult Path::GetCanonical(const String & path, String & canonicalPathOut) + { +#if defined(_WIN32) + // https://msdn.microsoft.com/en-us/library/506720ff.aspx + wchar_t* absPath = ::_wfullpath(nullptr, path.ToWString(), 0); + if (!absPath) + { + return SLANG_FAIL; + } + + canonicalPathOut = String::FromWString(absPath); + ::free(absPath); + return SLANG_OK; +#else + // http://man7.org/linux/man-pages/man3/realpath.3.html + char* canonicalPath = ::realpath(path.begin(), nullptr); + if (canonicalPath) + { + canonicalPathOut = canonicalPath; + ::free(canonicalPath); + return SLANG_OK; + } + return SLANG_FAIL; +#endif + } + Slang::String File::ReadAllText(const Slang::String & fileName) { StreamReader reader(new FileStream(fileName, FileMode::Open, FileAccess::Read, FileShare::ReadWrite)); @@ -152,4 +185,7 @@ namespace Slang StreamWriter writer(new FileStream(fileName, FileMode::Create)); writer.Write(text); } + + } + diff --git a/source/core/slang-io.h b/source/core/slang-io.h index 2f140c3ad..543b12adf 100644 --- a/source/core/slang-io.h +++ b/source/core/slang-io.h @@ -31,6 +31,8 @@ namespace Slang static String Combine(const String & path1, const String & path2); static String Combine(const String & path1, const String & path2, const String & path3); static bool CreateDir(const String & path); + + static SlangResult GetCanonical(const String & path, String& canonicalPathOut); }; } |
