From ed4b37906749dd7ba2da56af741f2c0826f222d1 Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Tue, 24 Jul 2012 12:11:20 -0700 Subject: Eliminated countFilesInDir boostified getCurPath for OSX --- indra/llvfs/lldir.h | 2 -- indra/llvfs/lldir_mac.cpp | 25 ++----------------------- indra/llvfs/lldir_mac.h | 1 - 3 files changed, 2 insertions(+), 26 deletions(-) (limited to 'indra/llvfs') diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index 5ee8bdb542..a8b204e63e 100644 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -73,8 +73,6 @@ class LLDir virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask); // pure virtual functions - virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0; - virtual std::string getCurPath() = 0; virtual BOOL fileExists(const std::string &filename) const = 0; diff --git a/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp index 489bc3e4a7..f0b46ade6d 100644 --- a/indra/llvfs/lldir_mac.cpp +++ b/indra/llvfs/lldir_mac.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include @@ -239,34 +240,12 @@ void LLDir_Mac::initAppDirs(const std::string &app_name, //dumpCurrentDirectories(); } -U32 LLDir_Mac::countFilesInDir(const std::string &dirname, const std::string &mask) -{ - U32 file_count = 0; - glob_t g; - - std::string tmp_str; - tmp_str = dirname; - tmp_str += mask; - - if(glob(tmp_str.c_str(), GLOB_NOSORT, NULL, &g) == 0) - { - file_count = g.gl_pathc; - - globfree(&g); - } - - return (file_count); -} - std::string LLDir_Mac::getCurPath() { - char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ - getcwd(tmp_str, LL_MAX_PATH); - return tmp_str; + return boost::filesystem::path( boost::filesystem::current_path() ).string(); } - BOOL LLDir_Mac::fileExists(const std::string &filename) const { struct stat stat_data; diff --git a/indra/llvfs/lldir_mac.h b/indra/llvfs/lldir_mac.h index d190d70be4..9f1938ae23 100644 --- a/indra/llvfs/lldir_mac.h +++ b/indra/llvfs/lldir_mac.h @@ -45,7 +45,6 @@ public: const std::string& app_read_only_data_dir); virtual std::string getCurPath(); - virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); virtual BOOL fileExists(const std::string &filename) const; /*virtual*/ std::string getLLPluginLauncher(); -- cgit v1.2.3 From 3b560d4c4902eff361ac308f56d982b1147739c4 Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Wed, 25 Jul 2012 16:03:50 -0700 Subject: Some cocoa that doesn't work --- indra/llvfs/lldir_mac.cpp | 32 ++++++++++++++++---------------- indra/llvfs/lldir_mac.h | 5 ----- 2 files changed, 16 insertions(+), 21 deletions(-) (limited to 'indra/llvfs') diff --git a/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp index f0b46ade6d..de3347cf63 100644 --- a/indra/llvfs/lldir_mac.cpp +++ b/indra/llvfs/lldir_mac.cpp @@ -38,6 +38,21 @@ #include #include +//#include "lldir_mac.mm" +// +//std::string getApplicationSupportFolder () +//{ +// std::string support_folder_str; +// CFArrayRef a = appSupport(); +// if (CFArrayGetCount(a) > 0) { +// CFStringRef s = CFArrayGetValueAtIndex(a, 0); +// char path[PATH_MAX]; +// CFStringGetFileSystemRepresentation(s, path, sizeof(path)); +// support_folder_str = std::string(path); +// } +// CFRelease(a); +// return support_folder_str; +//} // -------------------------------------------------------------------------------- @@ -110,8 +125,6 @@ static void FSRefToLLString(FSRef *fsRef, std::string &llString) LLDir_Mac::LLDir_Mac() { mDirDelimiter = "/"; - mCurrentDirIndex = -1; - mCurrentDirCount = -1; CFBundleRef mainBundleRef = NULL; CFURLRef executableURLRef = NULL; @@ -236,8 +249,6 @@ void LLDir_Mac::initAppDirs(const std::string &app_name, mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins"; } mCAFile = getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem"); - - //dumpCurrentDirectories(); } std::string LLDir_Mac::getCurPath() @@ -248,18 +259,7 @@ std::string LLDir_Mac::getCurPath() BOOL LLDir_Mac::fileExists(const std::string &filename) const { - struct stat stat_data; - // Check the age of the file - // Now, we see if the files we've gathered are recent... - int res = stat(filename.c_str(), &stat_data); - if (!res) - { - return TRUE; - } - else - { - return FALSE; - } + return boost::filesystem::exists(filename); } diff --git a/indra/llvfs/lldir_mac.h b/indra/llvfs/lldir_mac.h index 9f1938ae23..b8b9c6a9e7 100644 --- a/indra/llvfs/lldir_mac.h +++ b/indra/llvfs/lldir_mac.h @@ -49,11 +49,6 @@ public: /*virtual*/ std::string getLLPluginLauncher(); /*virtual*/ std::string getLLPluginFilename(std::string base_name); - -private: - int mCurrentDirIndex; - int mCurrentDirCount; - std::string mCurrentDir; }; #endif // LL_LLDIR_MAC_H -- cgit v1.2.3 From 1154d5afde0730b541716587ca3c5b962dba1b8d Mon Sep 17 00:00:00 2001 From: Aura Linden Date: Wed, 25 Jul 2012 16:08:27 -0700 Subject: Reverted boost/cocoa changes to purely Mountain Lion fixes. --- indra/llvfs/lldir.h | 4 +++- indra/llvfs/lldir_mac.cpp | 59 ++++++++++++++++++++++++++++++++--------------- indra/llvfs/lldir_mac.h | 8 ++++++- 3 files changed, 50 insertions(+), 21 deletions(-) (limited to 'indra/llvfs') diff --git a/indra/llvfs/lldir.h b/indra/llvfs/lldir.h index a8b204e63e..3b1883b5d8 100644 --- a/indra/llvfs/lldir.h +++ b/indra/llvfs/lldir.h @@ -1,4 +1,4 @@ -/** +/** * @file lldir.h * @brief Definition of directory utilities class * @@ -73,6 +73,8 @@ class LLDir virtual S32 deleteFilesInDir(const std::string &dirname, const std::string &mask); // pure virtual functions + virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask) = 0; + virtual std::string getCurPath() = 0; virtual BOOL fileExists(const std::string &filename) const = 0; diff --git a/indra/llvfs/lldir_mac.cpp b/indra/llvfs/lldir_mac.cpp index de3347cf63..9f60111275 100644 --- a/indra/llvfs/lldir_mac.cpp +++ b/indra/llvfs/lldir_mac.cpp @@ -22,7 +22,7 @@ * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ - */ + */ #if LL_DARWIN @@ -35,24 +35,8 @@ #include #include #include -#include #include -//#include "lldir_mac.mm" -// -//std::string getApplicationSupportFolder () -//{ -// std::string support_folder_str; -// CFArrayRef a = appSupport(); -// if (CFArrayGetCount(a) > 0) { -// CFStringRef s = CFArrayGetValueAtIndex(a, 0); -// char path[PATH_MAX]; -// CFStringGetFileSystemRepresentation(s, path, sizeof(path)); -// support_folder_str = std::string(path); -// } -// CFRelease(a); -// return support_folder_str; -//} // -------------------------------------------------------------------------------- @@ -125,6 +109,8 @@ static void FSRefToLLString(FSRef *fsRef, std::string &llString) LLDir_Mac::LLDir_Mac() { mDirDelimiter = "/"; + mCurrentDirIndex = -1; + mCurrentDirCount = -1; CFBundleRef mainBundleRef = NULL; CFURLRef executableURLRef = NULL; @@ -249,17 +235,52 @@ void LLDir_Mac::initAppDirs(const std::string &app_name, mSkinBaseDir = mAppRODataDir + mDirDelimiter + "skins"; } mCAFile = getExpandedFilename(LL_PATH_APP_SETTINGS, "CA.pem"); + + //dumpCurrentDirectories(); +} + +U32 LLDir_Mac::countFilesInDir(const std::string &dirname, const std::string &mask) +{ + U32 file_count = 0; + glob_t g; + + std::string tmp_str; + tmp_str = dirname; + tmp_str += mask; + + if(glob(tmp_str.c_str(), GLOB_NOSORT, NULL, &g) == 0) + { + file_count = g.gl_pathc; + + globfree(&g); + } + + return (file_count); } std::string LLDir_Mac::getCurPath() { - return boost::filesystem::path( boost::filesystem::current_path() ).string(); + char tmp_str[LL_MAX_PATH]; /* Flawfinder: ignore */ + getcwd(tmp_str, LL_MAX_PATH); + return tmp_str; } + BOOL LLDir_Mac::fileExists(const std::string &filename) const { - return boost::filesystem::exists(filename); + struct stat stat_data; + // Check the age of the file + // Now, we see if the files we've gathered are recent... + int res = stat(filename.c_str(), &stat_data); + if (!res) + { + return TRUE; + } + else + { + return FALSE; + } } diff --git a/indra/llvfs/lldir_mac.h b/indra/llvfs/lldir_mac.h index b8b9c6a9e7..64e9485757 100644 --- a/indra/llvfs/lldir_mac.h +++ b/indra/llvfs/lldir_mac.h @@ -22,7 +22,7 @@ * * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA * $/LicenseInfo$ - */ + */ #if !LL_DARWIN #error This header must not be included when compiling for any target other than Mac OS. Consider including lldir.h instead. @@ -45,10 +45,16 @@ public: const std::string& app_read_only_data_dir); virtual std::string getCurPath(); + virtual U32 countFilesInDir(const std::string &dirname, const std::string &mask); virtual BOOL fileExists(const std::string &filename) const; /*virtual*/ std::string getLLPluginLauncher(); /*virtual*/ std::string getLLPluginFilename(std::string base_name); + +private: + int mCurrentDirIndex; + int mCurrentDirCount; + std::string mCurrentDir; }; #endif // LL_LLDIR_MAC_H -- cgit v1.2.3