diff options
Diffstat (limited to 'source/core/slang-io.h')
| -rw-r--r-- | source/core/slang-io.h | 62 |
1 files changed, 6 insertions, 56 deletions
diff --git a/source/core/slang-io.h b/source/core/slang-io.h index aa4ccae42..acdcd0124 100644 --- a/source/core/slang-io.h +++ b/source/core/slang-io.h @@ -126,6 +126,12 @@ namespace Slang static String simplify(const UnownedStringSlice& path); static String simplify(const String& path) { return simplify(path.getUnownedSlice()); } + /// Given a path simplifies it such the the resultant path is absolute (ie contains no . or ..) + /// Can return '.' as the path as the directory 'root'. + static SlangResult simplifyAbsolute(const UnownedStringSlice& path, StringBuilder& outPath); + static SlangResult simplifyAbsolute(const String& path, StringBuilder& outPath) { return simplifyAbsolute(path.getUnownedSlice(), outPath); } + static SlangResult simplifyAbsolute(const char* path, StringBuilder& outPath) { return simplifyAbsolute(UnownedStringSlice(path), outPath); } + /// Simplifies the path split up static void simplify(List<UnownedStringSlice>& ioSplit); @@ -186,62 +192,6 @@ namespace Slang static bool isSafeURIChar(char ch); }; - // Helper class to clean up temporary files on dtor - class TemporaryFileSet: public RefObject - { - public: - typedef RefObject Super; - typedef TemporaryFileSet ThisType; - - void remove(const String& path) - { - if (const Index index = m_paths.indexOf(path) >= 0) - { - m_paths.removeAt(index); - } - } - - void add(const String& path) - { - if (m_paths.indexOf(path) < 0) - { - m_paths.add(path); - } - } - void add(const List<String>& paths) - { - for (const auto& path : paths) - { - add(path); - } - } - void clear() - { - m_paths.clear(); - } - - void swapWith(ThisType& rhs) - { - m_paths.swapWith(rhs.m_paths); - } - - ~TemporaryFileSet() - { - for (const auto& path : m_paths) - { - File::remove(path); - } - } - /// Default Ctor - TemporaryFileSet() {} - - List<String> m_paths; - - private: - // Disable ctor/assignment - TemporaryFileSet(const ThisType& rhs) = delete; - void operator=(const ThisType& rhs) = delete; - }; } #endif |
