genesis-3d_engine/Engine/foundation/io/win360/win360fswrapper.h
zhongdaohuan 6e8fbca745 genesis-3d engine version 1.3.
match the genesis editor version 1.3.0.653.
2014-05-05 14:50:33 +08:00

118 lines
5.1 KiB
Objective-C

/****************************************************************************
Copyright (c) 2007, Radon Labs GmbH
Copyright (c) 2011-2013,WebJet Business Division,CYOU
http://www.genesis-3d.com.cn
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
#pragma once
//------------------------------------------------------------------------------
/**
@class Win360::Win360FSWrapper
Internal filesystem wrapper for Win32/Xbox360. All paths must be native
paths (i.e. not contain Nebula assigns).
*/
//#include "core/types.h"
#include "util/string.h"
#include "util/array.h"
#include "io/stream.h"
#include "io/filetime.h"
//------------------------------------------------------------------------------
namespace Win360
{
class Win360FSWrapper
{
public:
typedef HANDLE Handle;
#if __XBOX360__
static const uchar FileDelimiter = '\\';
#endif
/// open a file
static Handle OpenFile(const Util::String& path, IO::Stream::AccessMode accessMode, IO::Stream::AccessPattern accessPattern, DWORD flagsAndAttributes = 0);
/// close a file
static void CloseFile(Handle h);
/// write to a file
static void Write(Handle h, const void* buf, IO::Stream::Size numBytes);
/// read from a file
static IO::Stream::Size Read(Handle h, void* buf, IO::Stream::Size numBytes);
/// seek in a file
static void Seek(Handle h, IO::Stream::Offset offset, IO::Stream::SeekOrigin orig);
/// get position in file
static IO::Stream::Position Tell(Handle h);
/// flush a file
static void Flush(Handle h);
/// return true if at end-of-file
static bool Eof(Handle h);
/// get size of a file in bytes
static IO::Stream::Size GetFileSize(Handle h);
/// set read-only status of a file
static void SetReadOnly(const Util::String& path, bool readOnly);
/// get read-only status of a file
static bool IsReadOnly(const Util::String& path);
/// delete a file
static bool DeleteFile(const Util::String& path);
/// delete an empty directory
static bool DeleteDirectory(const Util::String& path);
/// return true if a file exists
static bool FileExists(const Util::String& path);
/// return true if a directory exists
static bool DirectoryExists(const Util::String& path);
/// set the write-access time stamp of a file
static void SetFileWriteTime(const Util::String& path, IO::FileTime fileTime);
/// get the last write-access time stamp of a file
static IO::FileTime GetFileWriteTime(const Util::String& path);
/// create a directory
static bool CreateDirectory(const Util::String& path);
/// list all files in a directory
static Util::Array<Util::String> ListFiles(const Util::String& dirPath, const Util::String& pattern);
/// list all subdirectories in a directory
static Util::Array<Util::String> ListDirectories(const Util::String& dirPath, const Util::String& pattern);
/// get path to the current user's home directory (for user: standard assign)
static Util::String GetUserDirectory();
/// get path to the current user's appdata directory (for appdata: standard assign)
static Util::String GetAppDataDirectory();
/// get path to the current user's temp directory (for temp: standard assign)
static Util::String GetTempDirectory();
/// get path to the current application directory (for home: standard assign)
static Util::String GetHomeDirectory();
/// get path to the current bin directory (for bin: standard assign)
static Util::String GetBinDirectory();
/// get path to the "c:/program files" directory
static Util::String GetProgramsDirectory();
/// return true when the string is a device name (e.g. "C:")
static bool IsDeviceName(const Util::String& str);
/// get path to the editor asset directory (for editor: standard assign)
static Util::String GetEditorAssetDirectory();
private:
#if __WIN32__
/// convert UTF8 path name to WideChar path name
static void ConvertToWidePath(const Util::String& src, ushort* dst, SizeT dstNumBytes);
#endif
};
}; // namespace Win360
//------------------------------------------------------------------------------