1
0
mirror of https://foundry.openuru.org/gitblit/r/CWE-ou-minkata.git synced 2025-07-17 10:52:46 +00:00

Remove hsFiles in favor of plFilesystem stuff

This commit is contained in:
2013-01-20 20:17:39 -08:00
parent cc54fb07be
commit 2c028c4b07
51 changed files with 327 additions and 1249 deletions

View File

@ -43,7 +43,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsStream.h"
#include "plAgeDescription.h"
#include "plFile/hsFiles.h"
#include "plFile/plInitFileReader.h"
#include "plFile/plEncryptedStream.h"
#include "hsStringTokenizer.h"

View File

@ -51,7 +51,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAgeManifest.h"
#include "plFile/hsFiles.h"
#include "plFile/plInitFileReader.h"
#include "hsStringTokenizer.h"

View File

@ -44,7 +44,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsGeometry3.h"
#include "plgDispatch.h"
#include "plProfile.h"
#include "plFile/hsFiles.h"
#include "plWin32Sound.h"
#include "plWin32StreamingSound.h"

View File

@ -55,7 +55,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plAudioCore.h"
//#include "hsTimer.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plBufferedFileReader.h"
#include "plCachedFileReader.h"

View File

@ -49,7 +49,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plgDispatch.h"
#include "hsResMgr.h"
#include "pnMessage/plRefMsg.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plStatusLog/plStatusLog.h"
#include "hsTimer.h"

View File

@ -5,7 +5,6 @@ include_directories("../../PubUtilLib")
include_directories(${ZLIB_INCLUDE_DIR})
set(plFile_SOURCES
hsFiles.cpp
plBrowseFolder.cpp
plEncryptedStream.cpp
plInitFileReader.cpp
@ -13,16 +12,7 @@ set(plFile_SOURCES
plStreamSource.cpp
)
if(WIN32 AND NOT CYGWIN)
set(plFile_SOURCES ${plFile_SOURCES} hsFiles_Win.cpp)
endif(WIN32 AND NOT CYGWIN)
if(UNIX)
set(plFile_SOURCES ${plFile_SOURCES} hsFiles_Unix.cpp)
endif(UNIX)
set(plFile_HEADERS
hsFiles.h
plBrowseFolder.h
plEncryptedStream.h
plInitFileReader.h

View File

@ -1,182 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsFiles.h"
#include <string.h>
#include "hsExceptions.h"
#if HS_BUILD_FOR_WIN32
#define kDirChar '\\'
#else
#define kDirChar '/'
#endif
static const char* FindNameInPath(const char path[])
{
const char* name = ::strrchr(path, kDirChar);
if (name == nil)
name = path;
return name;
}
///////////////////////////////////////////////////////////////////////
hsFile::hsFile() : fPathAndName(nil), fFILE(nil)
{
}
hsFile::hsFile(const char pathAndName[]) : fPathAndName(nil), fFILE(nil)
{
if (pathAndName)
fPathAndName = hsStrcpy(pathAndName);
}
hsFile::~hsFile()
{
this->SetPathAndName(nil);
}
const char* hsFile::GetPathAndName()
{
return fPathAndName;
}
void hsFile::SetPathAndName(const char pathAndName[])
{
this->Close();
if (fPathAndName)
{ delete[] fPathAndName;
fPathAndName = nil;
}
if (pathAndName)
fPathAndName = hsStrcpy(pathAndName);
}
const char* hsFile::GetName()
{
return FindNameInPath(this->GetPathAndName());
}
FILE* hsFile::OpenFILE(const char mode[], bool throwIfFailure)
{
this->Close();
// We call the virtual method here rather than using
// fPathAndName directly, allowing a subclass to construct
// the name if necessary
//
const char* name = this->GetPathAndName();
if (name)
fFILE = ::fopen(name, mode);
hsThrowIfTrue(throwIfFailure && fFILE == nil);
return fFILE;
}
hsStream* hsFile::OpenStream(const char mode[], bool throwIfFailure)
{
FILE* file = this->OpenFILE(mode, throwIfFailure);
if (file)
{ hsUNIXStream* stream = new hsUNIXStream;
stream->SetFILE(file);
return stream;
}
return nil;
}
void hsFile::Close()
{
if (fFILE)
{ int err = ::fflush(fFILE);
hsIfDebugMessage(err != 0, "fflush failed", err);
err = ::fclose(fFILE);
hsIfDebugMessage(err != 0, "fclose failed", err);
fFILE = nil;
}
}
///////////////////////////////////////////////////////////////////////
bool hsFolderIterator::NextFileSuffix(const char suffix[])
{
while (this->NextFile())
{ const char* fileSuffix = ::strrchr(this->GetFileName(), '.');
if (fileSuffix != nil && stricmp(fileSuffix, suffix) == 0)
return true;
}
return false;
}
int hsFolderIterator::GetPathAndName(char pathandname[])
{
hsAssert(pathandname, "NULL path string");
const char* name = this->GetFileName();
int pathLen = strlen(fPath);
// add 1 for null terminator
int totalLen = pathLen + sizeof(kDirChar) + strlen(name) + 1;
hsAssert(totalLen <= kFolderIterator_MaxPath, "Overrun kFolderIterator_MaxPath");
if (pathandname)
{
strcpy(pathandname, fPath);
if (pathLen > 0 && pathandname[pathLen - 1] != kDirChar)
pathandname[pathLen++] = kDirChar;
strcpy(pathandname + pathLen, name);
}
return totalLen;
}
FILE* hsFolderIterator::OpenFILE(const char mode[])
{
char fileName[kFolderIterator_MaxPath];
(void)this->GetPathAndName(fileName);
return ::fopen(fileName, mode);
}

View File

@ -1,141 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#ifndef hsFiles_Defined
#define hsFiles_Defined
#include "hsStream.h"
#include <stdio.h>
#if HS_BUILD_FOR_UNIX
#include <limits.h>
#define kFolderIterator_MaxPath PATH_MAX
#define SetCurrentDirectory chdir
#else
#define kFolderIterator_MaxPath _MAX_PATH
#endif
///////////////////////////////////////////////////////////////////////
class hsFile {
hsFile& operator=(const hsFile&); // disallow assignment
protected:
char* fPathAndName;
FILE* fFILE;
public:
hsFile();
hsFile(const char pathAndName[]);
virtual ~hsFile();
const char* GetName();
virtual const char* GetPathAndName();
virtual void SetPathAndName(const char pathAndName[]);
virtual FILE* OpenFILE(const char mode[], bool throwIfFailure = false);
virtual hsStream* OpenStream(const char mode[], bool throwIfFailure = false);
virtual void Close(); // called automatically in the destructor
};
typedef hsFile hsUnixFile; // for compatibility
typedef hsFile hsOSFile;
///////////////////////////////////////////////////////////////////////
class hsFolderIterator {
char fPath[kFolderIterator_MaxPath];
struct hsFolderIterator_Data* fData;
bool fCustomFilter;
public:
#ifdef HS_BUILD_FOR_WIN32
hsFolderIterator(const char path[] = nil, bool useCustomFilter=false);
#else
hsFolderIterator(const char path[] = nil, bool unused=true);
hsFolderIterator(const struct FSSpec* spec); // Alt constructor
#endif
virtual ~hsFolderIterator();
const char* GetPath() const { return fPath; }
void SetPath(const char path[]);
void Reset();
bool NextFile();
bool NextFileSuffix(const char suffix[]);
const char* GetFileName() const;
int GetPathAndName(char pathandname[] = nil);
bool IsDirectory( void ) const;
FILE* OpenFILE(const char mode[]);
#if HS_BUILD_FOR_WIN32
void SetWinSystemDir(const char subdir[]); // e.g. "Fonts"
void SetFileFilterStr(const char filterStr[]); // e.g. "*.*"
#endif
};
#ifdef HS_BUILD_FOR_WIN32
// only implemented on Win32 for now
class hsWFolderIterator {
wchar_t fPath[kFolderIterator_MaxPath];
struct hsWFolderIterator_Data* fData;
bool fCustomFilter;
public:
hsWFolderIterator(const wchar_t path[] = nil, bool useCustomFilter=false);
virtual ~hsWFolderIterator();
const wchar_t* GetPath() const { return fPath; }
void SetPath(const wchar_t path[]);
void Reset();
bool NextFile();
bool NextFileSuffix(const wchar_t suffix[]);
const wchar_t* GetFileName() const;
int GetPathAndName(wchar_t pathandname[] = nil);
bool IsDirectory( void ) const;
FILE* OpenFILE(const wchar_t mode[]);
void SetWinSystemDir(const wchar_t subdir[]); // e.g. "Fonts"
void SetFileFilterStr(const wchar_t filterStr[]); // e.g. "*.*"
};
#endif
#endif

View File

@ -1,145 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsFiles.h"
#if HS_BUILD_FOR_UNIX
#include <errno.h>
#include <dirent.h>
#include <limits.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <unistd.h>
#include <glob.h>
#include <string>
#include "hsTemplates.h"
struct hsFolderIterator_Data {
glob_t fGlobBuf;
bool fInited;
int fCnt;
hsFolderIterator_Data() : fInited(false), fCnt(0) {}
// ~hsFolderIterator_Data() { fInited=false; globfree(&fData->fGlobBuf); }
};
hsFolderIterator::hsFolderIterator(const char path[], bool)
{
fData = new hsFolderIterator_Data;
this->SetPath(path);
}
hsFolderIterator::~hsFolderIterator()
{
this->Reset();
delete fData;
}
void hsFolderIterator::SetPath(const char path[])
{
fPath[0] = 0;
if (path)
{
::strcpy(fPath, path);
}
this->Reset();
}
void hsFolderIterator::Reset()
{
if (fData->fInited)
{
globfree(&fData->fGlobBuf);
fData->fCnt = 0;
fData->fInited=false;
}
}
bool hsFolderIterator::NextFile()
{
if (fData->fInited == false)
{
std::string path=fPath;
if(!(strchr(fPath,'*') || strchr(fPath,'?') || strchr(fPath,'[')))
{
if (fPath[strlen(fPath)-1] != PATH_SEPARATOR)
path = path + PATH_SEPARATOR_STR + "*";
else
path = path + "*";
}
if(glob(path.c_str(), 0, NULL, &fData->fGlobBuf) != 0 ) {
return false;
}
fData->fInited=true;
fData->fCnt = 0;
}
return fData->fCnt++ < fData->fGlobBuf.gl_pathc;
}
const char* hsFolderIterator::GetFileName() const
{
if (!fData->fInited || fData->fCnt > fData->fGlobBuf.gl_pathc)
throw "end of folder";
plFileName fn = fData->fGlobBuf.gl_pathv[fData->fCnt-1];
return fn.GetFileName().c_str();
}
bool hsFolderIterator::IsDirectory( void ) const
{
// rob, please forgive me, this is my best attempt...
if(fData->fCnt > fData->fGlobBuf.gl_pathc )
return false;
struct stat info;
const char* fn=fData->fGlobBuf.gl_pathv[fData->fCnt-1];
if( stat( fn, &info ) )
{
printf("Error calling stat(): %s errno=%d\n", strerror(errno), errno);
return false;
}
return ( info.st_mode & S_IFDIR ) ? true : false;
}
#endif

View File

@ -1,320 +0,0 @@
/*==LICENSE==*
CyanWorlds.com Engine - MMOG client, server and tools
Copyright (C) 2011 Cyan Worlds, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program 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
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
Additional permissions under GNU GPL version 3 section 7
If you modify this Program, or any covered work, by linking or
combining it with any of RAD Game Tools Bink SDK, Autodesk 3ds Max SDK,
NVIDIA PhysX SDK, Microsoft DirectX SDK, OpenSSL library, Independent
JPEG Group JPEG library, Microsoft Windows Media SDK, or Apple QuickTime SDK
(or a modified version of those libraries),
containing parts covered by the terms of the Bink SDK EULA, 3ds Max EULA,
PhysX SDK EULA, DirectX SDK EULA, OpenSSL and SSLeay licenses, IJG
JPEG Library README, Windows Media SDK EULA, or QuickTime SDK EULA, the
licensors of this Program grant you additional
permission to convey the resulting work. Corresponding Source for a
non-source form of such a combination shall include the source code for
the parts of OpenSSL and IJG JPEG Library used as well as that of the covered
work.
You can contact Cyan Worlds, Inc. by email legal@cyan.com
or by snail mail at:
Cyan Worlds, Inc.
14617 N Newport Hwy
Mead, WA 99021
*==LICENSE==*/
#include "hsFiles.h"
#include "HeadSpin.h"
#include "hsWindows.h"
#if HS_BUILD_FOR_WIN32
#include "hsExceptions.h"
struct hsFolderIterator_Data {
HANDLE fSearchHandle;
WIN32_FIND_DATA fFindData;
bool fValid;
};
hsFolderIterator::hsFolderIterator(const char path[], bool useCustomFilter)
{
fCustomFilter = useCustomFilter;
fData = new hsFolderIterator_Data;
fData->fSearchHandle = nil;
fData->fValid = true;
if(useCustomFilter)
{
this->SetFileFilterStr(path);
}
else
{
this->SetPath(path);
}
}
hsFolderIterator::~hsFolderIterator()
{
delete fData;
}
void hsFolderIterator::SetPath(const char path[])
{
fCustomFilter = false;
fPath[0] = 0;
if (path)
{
::strcpy(fPath, path);
// Make sure the dir ends with a slash
char lastchar = fPath[strlen(fPath)-1];
if (lastchar != '\\' && lastchar != '/')
strcat(fPath, "\\");
}
this->Reset();
}
void hsFolderIterator::SetWinSystemDir(const char subdir[])
{
int ret = GetWindowsDirectory(fPath, _MAX_PATH);
hsAssert(ret != 0, "Error getting windows directory in UseWindowsFontsPath");
if (subdir)
{ ::strcat(fPath, "\\");
::strcat(fPath, subdir);
::strcat(fPath, "\\");
}
this->Reset();
}
void hsFolderIterator::SetFileFilterStr(const char filterStr[])
{
fPath[0] = 0;
if (filterStr)
{
fCustomFilter = true;
::strcpy(fPath, filterStr);
}
this->Reset();
}
///////////////////////////////////////////////////////////////////////////////
void hsFolderIterator::Reset()
{
if (fData->fSearchHandle)
{ FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
}
fData->fValid = true;
}
bool hsFolderIterator::NextFile()
{
if (fData->fValid == false)
return false;
if (fData->fSearchHandle == nil)
{ int len = ::strlen(fPath);
if(fCustomFilter == false)
{
fPath[len] = '*';
fPath[len+1] = 0;
}
fData->fSearchHandle = FindFirstFile(fPath, &fData->fFindData);
fPath[len] = 0;
if (fData->fSearchHandle == INVALID_HANDLE_VALUE)
{ fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
else
{ if (FindNextFile(fData->fSearchHandle, &fData->fFindData) == false)
{ FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
return true;
}
bool hsFolderIterator::IsDirectory( void ) const
{
if( fData->fValid && ( fData->fFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
return true;
return false;
}
const char* hsFolderIterator::GetFileName() const
{
if (fData->fValid == false)
hsThrow( "end of folder");
return fData->fFindData.cFileName;
}
///////////////////////////////////////////////////////////////////////////////
struct hsWFolderIterator_Data {
HANDLE fSearchHandle;
WIN32_FIND_DATAW fFindData;
bool fValid;
};
hsWFolderIterator::hsWFolderIterator(const wchar_t path[], bool useCustomFilter)
{
fCustomFilter = useCustomFilter;
fData = new hsWFolderIterator_Data;
fData->fSearchHandle = nil;
fData->fValid = true;
if(useCustomFilter)
SetFileFilterStr(path);
else
SetPath(path);
}
hsWFolderIterator::~hsWFolderIterator()
{
delete fData;
}
void hsWFolderIterator::SetPath(const wchar_t path[])
{
fCustomFilter = false;
fPath[0] = 0;
if (path)
{
wcscpy(fPath, path);
// Make sure the dir ends with a slash
wchar_t lastchar = fPath[wcslen(fPath)-1];
if (lastchar != L'\\' && lastchar != L'/')
wcscat(fPath, L"\\");
}
Reset();
}
void hsWFolderIterator::SetWinSystemDir(const wchar_t subdir[])
{
int ret = GetWindowsDirectoryW(fPath, _MAX_PATH);
hsAssert(ret != 0, "Error getting windows directory in UseWindowsFontsPath");
if (subdir)
{
wcscat(fPath, L"\\");
wcscat(fPath, subdir);
wcscat(fPath, L"\\");
}
Reset();
}
void hsWFolderIterator::SetFileFilterStr(const wchar_t filterStr[])
{
fPath[0] = 0;
if (filterStr)
{
fCustomFilter = true;
wcscpy(fPath, filterStr);
}
Reset();
}
///////////////////////////////////////////////////////////////////////////////
void hsWFolderIterator::Reset()
{
if (fData->fSearchHandle)
{
FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
}
fData->fValid = true;
}
bool hsWFolderIterator::NextFile()
{
if (fData->fValid == false)
return false;
if (fData->fSearchHandle == nil)
{
int len = wcslen(fPath);
if(fCustomFilter == false)
{
fPath[len] = L'*';
fPath[len+1] = L'\0';
}
fData->fSearchHandle = FindFirstFileW(fPath, &fData->fFindData);
fPath[len] = 0;
if (fData->fSearchHandle == INVALID_HANDLE_VALUE)
{
fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
else
{
if (FindNextFileW(fData->fSearchHandle, &fData->fFindData) == false)
{
FindClose(fData->fSearchHandle);
fData->fSearchHandle = nil;
fData->fValid = false;
return false;
}
}
return true;
}
bool hsWFolderIterator::IsDirectory( void ) const
{
if( fData->fValid && ( fData->fFindData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) )
return true;
return false;
}
const wchar_t* hsWFolderIterator::GetFileName() const
{
if (fData->fValid == false)
hsThrow( "end of folder");
return fData->fFindData.cFileName;
}
#endif // HS_BUILD_FOR_WIN32

View File

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include <string>
#include "hsFiles.h"
#include "plStreamSource.h"
#include "plSecureStream.h"
#include "plEncryptedStream.h"
@ -106,8 +105,7 @@ std::vector<plFileName> plStreamSource::GetListOfNames(const plFileName& dir, co
// loop through all the file data records, and create the list
std::vector<plFileName> retVal;
decltype(fFileData.begin()) curData;
for (curData = fFileData.begin(); curData != fFileData.end(); curData++)
for (auto curData = fFileData.begin(); curData != fFileData.end(); curData++)
{
if ((curData->second.fDir == sDir) && (curData->second.fExt == ext))
retVal.push_back(curData->second.fFilename);
@ -116,15 +114,11 @@ std::vector<plFileName> plStreamSource::GetListOfNames(const plFileName& dir, co
#ifndef PLASMA_EXTERNAL_RELEASE
// in internal releases, we can use on-disk files if they exist
// Build the search string as "dir/*.ext"
plString searchStr = plFileName::Join(sDir, "*." + ext).AsString();
hsFolderIterator folderIter(searchStr.c_str(), true);
while (folderIter.NextFile())
std::vector<plFileName> files = plFileSystem::ListDir(sDir, ("*." + ext).c_str());
for (auto iter = files.begin(); iter != files.end(); ++iter)
{
plFileName filename = plFileName::Join(sDir, folderIter.GetFileName());
if (fFileData.find(filename) == fFileData.end()) // we haven't added it yet
retVal.push_back(filename);
if (fFileData.find(*iter) == fFileData.end()) // we haven't added it yet
retVal.push_back(*iter);
}
#endif // PLASMA_EXTERNAL_RELEASE

View File

@ -1063,7 +1063,7 @@ uint8_t *plFont::IGetFreeCharData( uint32_t &newOffset )
//// LoadFromP2FFile //////////////////////////////////////////////////////////
// Handy quick wrapper
bool plFont::LoadFromP2FFile( const char *path )
bool plFont::LoadFromP2FFile( const plFileName &path )
{
hsUNIXStream stream;
if( stream.Open( path, "rb" ) )

View File

@ -289,7 +289,7 @@ class plFont : public hsKeyedObject
bool LoadFromBDF( const char *path, plBDFConvertCallback *callback );
bool LoadFromBDFStream( hsStream *stream, plBDFConvertCallback *callback );
bool LoadFromP2FFile( const char *path );
bool LoadFromP2FFile( const plFileName &path );
bool ReadRaw( hsStream *stream );
bool WriteRaw( hsStream *stream );

View File

@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plFont.h"
#include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
#include "pnMessage/plRefMsg.h"
#include "hsResMgr.h"
@ -71,7 +70,6 @@ plFontCache *plFontCache::fInstance = nil;
plFontCache::plFontCache()
{
fCustFontDir = nil;
RegisterAs( kFontCache_KEY );
fInstance = this;
}
@ -79,7 +77,6 @@ plFontCache::plFontCache()
plFontCache::~plFontCache()
{
Clear();
delete [] fCustFontDir;
fInstance = nil;
}
@ -151,46 +148,38 @@ plFont *plFontCache::GetFont( const char *face, uint8_t size, uint32_t fontFlag
return nil;
}
void plFontCache::LoadCustomFonts( const char *dir )
void plFontCache::LoadCustomFonts( const plFileName &dir )
{
delete [] fCustFontDir;
fCustFontDir = ( dir != nil ) ? hsStrcpy( dir ) : nil;
fCustFontDir = dir;
ILoadCustomFonts();
}
void plFontCache::ILoadCustomFonts( void )
void plFontCache::ILoadCustomFonts( void )
{
if( fCustFontDir == nil )
if (!fCustFontDir.IsValid())
return;
// Iterate through all the custom fonts in our dir
hsFolderIterator iter( fCustFontDir );
char fileName[ kFolderIterator_MaxPath ];
hsFolderIterator iter2( fCustFontDir );
while( iter2.NextFileSuffix( ".p2f" ) )
std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, "*.p2f");
for (auto iter = fonts.begin(); iter != fonts.end(); ++iter)
{
iter2.GetPathAndName( fileName );
plFont *font = new plFont;
if( !font->LoadFromP2FFile( fileName ) )
if (!font->LoadFromP2FFile(*iter))
delete font;
else
{
plString keyName;
if( font->GetKey() == nil )
if (font->GetKey() == nil)
{
keyName = plString::Format( "%s-%d", font->GetFace(), font->GetSize() );
hsgResMgr::ResMgr()->NewKey( keyName, font, plLocation::kGlobalFixedLoc );
}
hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(),
new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ),
plRefFlags::kActiveRef );
hsgResMgr::ResMgr()->AddViaNotify( font->GetKey(),
new plGenRefMsg( GetKey(), plRefMsg::kOnCreate, 0, -1 ),
plRefFlags::kActiveRef );
//plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName );
//plStatusLog::AddLineS( "pipeline.log", "FontCache: Added custom font %s", keyName.c_str() );
}
}

View File

@ -59,6 +59,7 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "HeadSpin.h"
#include "hsTemplates.h"
#include "pnKeyedObject/hsKeyedObject.h"
#include "plFileSystem.h"
//// Class Definition /////////////////////////////////////////////////////////
@ -69,9 +70,9 @@ class plFontCache : public hsKeyedObject
protected:
hsTArray<plFont *> fCache;
char *fCustFontDir;
plFileName fCustFontDir;
static plFontCache *fInstance;
static plFontCache *fInstance;
void ILoadCustomFonts( void );
@ -96,7 +97,7 @@ class plFontCache : public hsKeyedObject
// void FreeFont( HFONT font );
void Clear( void );
void LoadCustomFonts( const char *dir );
void LoadCustomFonts( const plFileName &dir );
// Our custom font extension
static const char* kCustFontExtension;

View File

@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plWinFontCache.h"
#include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
#include "plGImage/plDynSurfaceWriter.h"
#if HS_BUILD_FOR_WIN32
@ -234,11 +233,11 @@ void plWinFontCache::Clear( void )
for( i = 0; i < fCustFonts.GetCount(); i++ )
{
#if (_WIN32_WINNT >= 0x0500)
if( plDynSurfaceWriter::CanHandleLotsOfThem() )
RemoveFontResourceEx( fCustFonts[ i ]->fFilename, FR_PRIVATE, 0 );
if (plDynSurfaceWriter::CanHandleLotsOfThem())
RemoveFontResourceExW(fCustFonts[i]->fFilename.AsString().ToWchar(), FR_PRIVATE, 0);
else
#endif
if( RemoveFontResource( fCustFonts[ i ]->fFilename ) == 0 )
if (RemoveFontResourceW(fCustFonts[i]->fFilename.AsString().ToWchar()) == 0)
{
int q= 0;
DWORD e = GetLastError();
@ -267,31 +266,27 @@ void plWinFontCache::ILoadCustomFonts( void )
return;
// Iterate through all the custom fonts in our dir
hsFolderIterator iter( fCustFontDir );
char fileName[ kFolderIterator_MaxPath ];
int numAdded;
int numAdded;
while( iter.NextFileSuffix( kCustFontExtension ) )
std::vector<plFileName> fonts = plFileSystem::ListDir(fCustFontDir, kCustFontExtension);
for (auto iter = fonts.begin(); iter != fonts.end(); ++iter)
{
iter.GetPathAndName( fileName );
// Note that this call can be translated as "does my OS suck?"
#if (_WIN32_WINNT >= 0x0500)
if( plDynSurfaceWriter::CanHandleLotsOfThem() )
numAdded = AddFontResourceEx( fileName, FR_PRIVATE, 0 );
numAdded = AddFontResourceExW(iter->AsString().ToWchar(), FR_PRIVATE, 0);
else
#endif
numAdded = AddFontResource( fileName );
numAdded = AddFontResourceW(iter->AsString().ToWchar());
if( numAdded > 0 )
{
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", fileName, numAdded );
fCustFonts.Append( new plCustFont( fileName ) );
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Added custom font %s, %d fonts", iter->GetFileName().c_str(), numAdded );
fCustFonts.Append(new plCustFont(*iter));
}
else
{
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Unable to load custom font %s", fileName );
plStatusLog::AddLineS( "pipeline.log", "WinFontCache: Unable to load custom font %s", iter->GetFileName().c_str() );
}
}
}

View File

@ -90,10 +90,9 @@ class plWinFontCache
class plCustFont
{
public:
char *fFilename;
plFileName fFilename;
plCustFont( const char *c ) { fFilename = hsStrcpy( c ); }
~plCustFont() { delete [] fFilename; }
plCustFont(const plFileName &c) { fFilename = c; }
};
bool fInShutdown;

View File

@ -63,7 +63,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plNetMessage/plNetMessage.h"
#include "plAvatar/plAvatarMgr.h"
#include "plAvatar/plArmatureMod.h"
#include "plFile/hsFiles.h"
/*****************************************************************************
@ -305,15 +304,14 @@ void plNetLinkingMgr::SetEnabled( bool b )
////////////////////////////////////////////////////////////////////
// static
std::string plNetLinkingMgr::GetProperAgeName( const char * ageName )
plString plNetLinkingMgr::GetProperAgeName( const plString & ageName )
{
plNetClientMgr * nc = plNetClientMgr::GetInstance();
hsFolderIterator it("dat" PATH_SEPARATOR_STR "*.age", true);
while ( it.NextFile() )
std::vector<plFileName> files = plFileSystem::ListDir("dat", "*.age");
for (auto iter = files.begin(); iter != files.end(); ++iter)
{
std::string work = it.GetFileName();
work.erase( work.find( ".age" ) );
if ( stricmp( ageName, work.c_str() )==0 )
plString work = iter->GetFileNameNoExt();
if (ageName.CompareI(work) == 0)
return work;
}
return ageName;

View File

@ -158,7 +158,7 @@ public:
const plNetServerSessionInfo * GetLobbyServerInfo( void ) const { return &fLobbyInfo;}
// helpers
static std::string GetProperAgeName( const char * ageName ); // attempt to fix wrong case age name.
static plString GetProperAgeName( const plString & ageName ); // attempt to fix wrong case age name.
private:
bool fLinkingEnabled;

View File

@ -57,7 +57,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "plMessage/plAgeLoadedMsg.h"
#include "plStatusLog/plStatusLog.h"
#include "plFile/hsFiles.h"
plNetClientRecorder::plNetClientRecorder(TimeWrapper* timeWrapper) :
fTimeWrapper(timeWrapper)

View File

@ -47,7 +47,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnKeyedObject/plKeyImp.h"
#include "plStatusLog/plStatusLog.h"
#include "pnFactory/plFactory.h"
#include "plFile/hsFiles.h"
#include "plVersion.h"

View File

@ -59,7 +59,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "pnMessage/plObjRefMsg.h"
#include "plMessage/plAgeLoadedMsg.h"
#include "pnMessage/plClientMsg.h"
#include "plFile/hsFiles.h"
#include "pnFactory/plCreator.h"
#include "pnNetCommon/plSynchedObject.h"
#include "pnNetCommon/plNetApp.h"
@ -130,13 +129,10 @@ bool plResManager::IInit()
{
// We want to go through all the data files in our data path and add new
// plRegistryPageNodes to the regTree for each
hsFolderIterator pathIterator(fDataPath.AsString().c_str());
while (pathIterator.NextFileSuffix(".prp"))
std::vector<plFileName> prpFiles = plFileSystem::ListDir(fDataPath, "*.prp");
for (auto iter = prpFiles.begin(); iter != prpFiles.end(); ++iter)
{
char fileName[kFolderIterator_MaxPath];
pathIterator.GetPathAndName(fileName);
plRegistryPageNode* node = new plRegistryPageNode(fileName);
plRegistryPageNode* node = new plRegistryPageNode(*iter);
plPageInfo pi = node->GetPageInfo();
fAllPages[pi.GetLocation()] = node;
}

View File

@ -41,7 +41,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
*==LICENSE==*/
#include "HeadSpin.h"
#include "plSDL.h"
#include "plFile/hsFiles.h"
#include "plFile/plStreamSource.h"
#include "pnNetCommon/pnNetCommon.h"
#include "pnNetCommon/plNetApp.h"

View File

@ -61,7 +61,6 @@ You can contact Cyan Worlds, Inc. by email legal@cyan.com
#include "hsTemplates.h"
#include "hsTimer.h"
#include "plStatusLog.h"
#include "plFile/hsFiles.h"
#include "plUnifiedTime/plUnifiedTime.h"
#include "plProduct.h"
@ -252,29 +251,12 @@ bool plStatusLogMgr::DumpLogs( const plFileName &newFolderName )
newPath = newFolderName;
plFileSystem::CreateDir(newPath, true);
#if HS_BUILD_FOR_WIN32
hsWFolderIterator folderIterator;
if (basePath.IsValid())
folderIterator.SetPath(basePath.AsString().ToWchar());
else
folderIterator.SetPath(L".");
while (folderIterator.NextFile())
{
if (folderIterator.IsDirectory())
continue;
plFileName baseFilename = plString::FromWchar(folderIterator.GetFileName());
plFileName source;
if (basePath.IsValid())
source = plFileName::Join(basePath, baseFilename);
else
source = baseFilename;
plFileName destination = plFileName::Join(newPath, baseFilename);
retVal = (plFileSystem::Copy(source, destination) != 0);
std::vector<plFileName> files = plFileSystem::ListDir(basePath);
for (auto iter = files.begin(); iter != files.end(); ++iter) {
plFileName destination = plFileName::Join(newPath, iter->GetFileName());
retVal = plFileSystem::Copy(*iter, destination);
}
#endif
return retVal;
}