#pragma region CPL License /* Nuclex Native Framework Copyright (C) 2002-2013 Nuclex Development Labs This library is free software; you can redistribute it and/or modify it under the terms of the IBM Common Public License as published by the IBM Corporation; either version 1.0 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the IBM Common Public License for more details. You should have received a copy of the IBM Common Public License along with this library */ #pragma endregion // CPL License #ifndef NUCLEX_STORAGE_FILESYSTEM_LINUXPATHFORMAT_H #define NUCLEX_STORAGE_FILESYSTEM_LINUXPATHFORMAT_H #include "Nuclex/Storage/Config.h" #if defined(NUCLEX_STORAGE_LINUX) #include namespace Nuclex { namespace Storage { namespace FileSystem { // ------------------------------------------------------------------------------------------- // /// Defines the path format used on Linux-based systems class LinuxPathFormat { /// The preferred path separator of this platform public: static const char PathSeparator; /// Whether this platform has a current working directory public: static const bool HasCurrentWorkingDirectory; /// Determines if the specified character is a path separator /// Character that will be checked for being a path separator /// True if the specified character is a path separator public: static bool IsPathSeparator(char character) { return (character == PathSeparator); } /// Always returns false since Linux doesn't use drive letters /// False, always public: static bool ContainsDriveLetter(const std::string &) { return false; } /// Returns the current working directory /// The current working directory public: static std::string GetCurrentWorkingDirectory(); /// Determines if the specified path is an absolute path /// Path that will be checked /// True if the specified path is an absolute path public: static bool IsAbsolutePath(const std::string &path) { return (GetAbsolutePathPrefixLength(path) > 0); } /// Determines the length of the absolute path prefix in the path /// /// Path in which the length of the absolute path prefix will be determined /// /// The length of the absolute path prefix in the specified path /// /// This returns the number of characters that qualify the specified path as /// an absolute path. The path "/tmp/x" would for example return 1 since the starting /// slash makes this an absolute path. "~/myfile" would return 2 since both /// the home directory and slash are required. "moo" returns 0 since it is relative. /// public: static std::size_t GetAbsolutePathPrefixLength(const std::string &path); }; // ------------------------------------------------------------------------------------------- // }}} // namespace Nuclex::Storage::FileSystem #endif // defined(NUCLEX_STORAGE_LINUX) #endif // NUCLEX_STORAGE_FILESYSTEM_LINUXPATHFORMAT_H