diff --git a/Standard Gaming Platform/CMakeLists.txt b/Standard Gaming Platform/CMakeLists.txt index 70404804..f56cf667 100644 --- a/Standard Gaming Platform/CMakeLists.txt +++ b/Standard Gaming Platform/CMakeLists.txt @@ -9,7 +9,6 @@ set(SGPSrc "${CMAKE_CURRENT_SOURCE_DIR}/DirectDraw Calls.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/DirectX Common.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/English.cpp" -"${CMAKE_CURRENT_SOURCE_DIR}/FileCat.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/FileMan.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Flic.cpp" "${CMAKE_CURRENT_SOURCE_DIR}/Font.cpp" diff --git a/Standard Gaming Platform/FileCat.cpp b/Standard Gaming Platform/FileCat.cpp deleted file mode 100644 index a977d597..00000000 --- a/Standard Gaming Platform/FileCat.cpp +++ /dev/null @@ -1,100 +0,0 @@ -// -// Snap: Implementation of the TFileCat class -// -#include "FileCat.h" -#include "readdir.h" - - -// Remove a slash or backslash (if any) from the end of a string -void ChompSlash(std::string& s) -{ - if ( s.empty() ) return; - - if ( *s.rbegin() == '\\' || *s.rbegin() == '/' ) { - s.erase( s.length() - 1 ); - } -} - - -// Build a new file catalogue by recursively traversing the root directory -void TFileCat::NewCat(std::string root) -{ - fRootDir = root; - ChompSlash(fRootDir); - - fFileCat.clear(); - - TraverseDir(fRootDir); -} - - -// Look for a given file in the catalogue -// Unless pathIncludesRoot == true, will prepend the root directory to path -bool TFileCat::FindFile(std::string path, bool pathIncludesRoot) const -{ - if (pathIncludesRoot) return fFileCat.find(path) != fFileCat.end(); - else return fFileCat.find(fRootDir + '\\' + path) != fFileCat.end(); -} - - -// Delete a given file from the catalogue -// Unless pathIncludesRoot == true, will prepend the root directory to path -size_t TFileCat::RemoveFile(std::string path, bool pathIncludesRoot) -{ - if (pathIncludesRoot) return fFileCat.erase(path); - else return fFileCat.erase(fRootDir + '\\' + path); -} - - -// Delete all files from a given directory in the catalogue -// Unless pathIncludesRoot == true, will prepend the root directory to path -size_t TFileCat::RemoveDir(std::string dir, bool pathIncludesRoot) -{ - if ( !pathIncludesRoot ) dir = fRootDir + '\\' + dir; - ChompSlash(dir); - std::string dirlower = dir + '\\'; - std::string dirupper = dir + char('\\'+1); - - TCatalogue::iterator upper = fFileCat.upper_bound(dirupper); - TCatalogue::iterator lower; - - int deleted = 0; - - while ( ( lower = fFileCat.lower_bound(dirlower) ) != upper) { - fFileCat.erase(lower); - deleted++; - } - - return deleted; -} - - -// Recursively traverse a directory, adding regular files to the catalogue -void TFileCat::TraverseDir(std::string dir, int depth) -{ - using std::string; - static string dot( "."); - static string dotdot( ".."); - static string svn( ".svn"); - - if (!dir.empty()) dir += '\\'; - - TReadDir readDir((dir + "*").c_str()); - - char const* fileName; - unsigned attrib; - - while ( readDir.NextFile(fileName, attrib) ) { - if (dot == fileName || dotdot == fileName || svn == fileName) continue; - - string fullPath = dir + fileName; - - if (attrib & FILE_ATTRIBUTE_DIRECTORY) { - if (depth < 0) TraverseDir(fullPath); - else if (depth > 0) TraverseDir(fullPath, depth-1); - } - else { - fFileCat.insert(fullPath); - } - } -} diff --git a/Standard Gaming Platform/FileCat.h b/Standard Gaming Platform/FileCat.h deleted file mode 100644 index 38d1fc27..00000000 --- a/Standard Gaming Platform/FileCat.h +++ /dev/null @@ -1,48 +0,0 @@ -// -// Snap: Declaration of the TFileCat class -// -// This class catalogues files in a directory and all its subdirectories -// -#ifndef FILECAT_H -#define FILECAT_H - -#include "stringicmp.h" -#include -#include - - -class TFileCat { -public: - - TFileCat(std::string root) { NewCat(root); } - TFileCat() {} - - // Build a new file catalogue by recursively traversing the root directory - void NewCat(std::string root); - - std::string GetRootDir() const { return fRootDir; } - - // Look for a given file in the catalogue - // Unless pathIncludesRoot == true, will prepend the root directory to path - bool FindFile(std::string path, bool pathIncludesRoot = false) const; - - // Delete a given file from the catalogue - // Unless pathIncludesRoot == true, will prepend the root directory to path - size_t RemoveFile(std::string path, bool pathIncludesRoot = false); - - // Delete all files from a given directory in the catalogue - // Unless pathIncludesRoot == true, will prepend the root directory to path - size_t RemoveDir(std::string dir, bool pathIncludesRoot = false); - -private: - - typedef std::set TCatalogue; - - std::string fRootDir; - TCatalogue fFileCat; - - // Recursively traverse a directory, adding regular files to the catalogue - void TraverseDir(std::string dir, int depth = -1); -}; - -#endif // FILECAT_H diff --git a/Standard Gaming Platform/FileMan.h b/Standard Gaming Platform/FileMan.h index 5fac1d92..bc860fc8 100644 --- a/Standard Gaming Platform/FileMan.h +++ b/Standard Gaming Platform/FileMan.h @@ -20,10 +20,8 @@ //************************************************************************** #include "types.h" - #include "Windows.h" -#include "FileCat.h" //************************************************************************** diff --git a/ext/export/src/export/sti/Image.cpp b/ext/export/src/export/sti/Image.cpp index cc719d69..2db90738 100644 --- a/ext/export/src/export/sti/Image.cpp +++ b/ext/export/src/export/sti/Image.cpp @@ -406,7 +406,18 @@ vfs::Path CreateFileName(vfs::Path const& sOutPathName, vfs::Path const& sFileNa outPath += vfs::Path(fullpath.str()); return outPath; } + #if 0 +// Remove a slash or backslash (if any) from the end of a string +void ChompSlash(std::string& s) +{ + if (s.empty()) return; + + if (*s.rbegin() == '\\' || *s.rbegin() == '/') { + s.erase(s.length() - 1); + } +} + bool CImage::WriteAsBMPs(vfs_string sOutPathName) { if(!this->LoadData())