Nebula
Loading...
Searching...
No Matches
win32fswrapper.h
Go to the documentation of this file.
1#pragma once
2//------------------------------------------------------------------------------
13#include "core/types.h"
14#include "util/string.h"
15#include "util/array.h"
16#include "io/stream.h"
17#include "io/filetime.h"
18
19//------------------------------------------------------------------------------
20namespace Win32
21{
23{
24public:
25 typedef HANDLE Handle;
26
28 static Handle OpenFile(const Util::String& path, IO::Stream::AccessMode accessMode, IO::Stream::AccessPattern accessPattern, DWORD flagsAndAttributes = 0);
30 static void CloseFile(Handle h);
32 static void Write(Handle h, const void* buf, IO::Stream::Size numBytes);
34 static IO::Stream::Size Read(Handle h, void* buf, IO::Stream::Size numBytes);
36 static char* Map(Handle h, IO::Stream::AccessMode accessMode, Handle& mappedHandle);
38 static void Unmap(Handle mapHandle, char* buf);
40 static void Seek(Handle h, IO::Stream::Offset offset, IO::Stream::SeekOrigin orig);
44 static void Flush(Handle h);
46 static bool Eof(Handle h);
50 static void SetReadOnly(const Util::String& path, bool readOnly);
52 static bool IsReadOnly(const Util::String& path);
54 static bool IsLocked(const Util::String& path);
56 static bool DeleteFile(const Util::String& path);
58 static bool ReplaceFile(const Util::String& source, const Util::String& target);
60 static bool DeleteDirectory(const Util::String& path);
62 static bool FileExists(const Util::String& path);
64 static bool DirectoryExists(const Util::String& path);
66 static void SetFileWriteTime(const Util::String& path, IO::FileTime fileTime);
68 static IO::FileTime GetFileWriteTime(const Util::String& path);
70 static bool CreateDirectory(const Util::String& path);
74 static Util::Array<Util::String> ListFiles(const Util::String& dirPath, const Util::String& pattern);
76 static Util::Array<Util::String> ListDirectories(const Util::String& dirPath, const Util::String& pattern);
92 static bool IsDeviceName(const Util::String& str);
93
94private:
95
97 static void ConvertToWidePath(const Util::String& src, ushort* dst, SizeT dstNumBytes);
98};
99
100}; // namespace Win32
101//------------------------------------------------------------------------------
Defines a file-access timestamp.
SeekOrigin
seek origins
Definition stream.h:54
int64_t Offset
Definition stream.h:33
int64_t Position
typedefs
Definition stream.h:32
int64_t Size
Definition stream.h:34
AccessMode
access modes
Definition stream.h:38
AccessPattern
access prefered pattern
Definition stream.h:47
Nebula's dynamic array class.
Definition array.h:60
Internal filesystem wrapper for Win32.
Definition win32fswrapper.h:23
static Util::String GetCurrentDirectory()
get current working directory
Definition win32fswrapper.cc:611
static IO::Stream::Size Read(Handle h, void *buf, IO::Stream::Size numBytes)
read from a file
Definition win32fswrapper.cc:127
static bool ReplaceFile(const Util::String &source, const Util::String &target)
rename a file
Definition win32fswrapper.cc:340
static bool IsDeviceName(const Util::String &str)
return true when the string is a device name (e.g. "C:")
Definition win32fswrapper.cc:710
static void Seek(Handle h, IO::Stream::Offset offset, IO::Stream::SeekOrigin orig)
seek in a file
Definition win32fswrapper.cc:193
static void SetFileWriteTime(const Util::String &path, IO::FileTime fileTime)
set the write-access time stamp of a file
Definition win32fswrapper.cc:414
static bool IsReadOnly(const Util::String &path)
get read-only status of a file
Definition win32fswrapper.cc:292
static IO::Stream::Position Tell(Handle h)
get position in file
Definition win32fswrapper.cc:222
HANDLE Handle
Definition win32fswrapper.h:25
static void SetReadOnly(const Util::String &path, bool readOnly)
set read-only status of a file
Definition win32fswrapper.cc:270
static IO::FileTime GetFileWriteTime(const Util::String &path)
get the last write-access time stamp of a file
Definition win32fswrapper.cc:434
static bool DirectoryExists(const Util::String &path)
return true if a directory exists
Definition win32fswrapper.cc:391
static void ConvertToWidePath(const Util::String &src, ushort *dst, SizeT dstNumBytes)
convert UTF8 path name to WideChar path name
static bool Eof(Handle h)
return true if at end-of-file
Definition win32fswrapper.cc:244
static Util::Array< Util::String > ListFiles(const Util::String &dirPath, const Util::String &pattern)
list all files in a directory
Definition win32fswrapper.cc:487
static Util::String GetProgramsDirectory()
get path to the "c:/program files" directory
Definition win32fswrapper.cc:592
static char * Map(Handle h, IO::Stream::AccessMode accessMode, Handle &mappedHandle)
map file to virtual memory
Definition win32fswrapper.cc:146
static Handle OpenFile(const Util::String &path, IO::Stream::AccessMode accessMode, IO::Stream::AccessPattern accessPattern, DWORD flagsAndAttributes=0)
open a file
Definition win32fswrapper.cc:28
static void Flush(Handle h)
flush a file
Definition win32fswrapper.cc:233
static Util::Array< Util::String > ListDirectories(const Util::String &dirPath, const Util::String &pattern)
list all subdirectories in a directory
Definition win32fswrapper.cc:521
static Util::String GetUserDirectory()
get path to the current user's home directory (for user: standard assign)
Definition win32fswrapper.cc:556
static void Unmap(Handle mapHandle, char *buf)
unmap file
Definition win32fswrapper.cc:182
static bool CreateDirectory(const Util::String &path)
create a directory
Definition win32fswrapper.cc:457
static bool DeleteDirectory(const Util::String &path)
delete an empty directory
Definition win32fswrapper.cc:354
static bool IsLocked(const Util::String &path)
get locked status of file
Definition win32fswrapper.cc:307
static Util::String GetAppDataDirectory()
get path to the current user's appdata directory (for appdata: standard assign)
Definition win32fswrapper.cc:574
static bool FileExists(const Util::String &path)
return true if a file exists
Definition win32fswrapper.cc:368
static Util::String GetHomeDirectory()
get path to the current application directory (for home: standard assign)
Definition win32fswrapper.cc:658
static bool DeleteFile(const Util::String &path)
delete a file
Definition win32fswrapper.cc:328
static void CloseFile(Handle h)
close a file
Definition win32fswrapper.cc:97
static IO::Stream::Size GetFileSize(Handle h)
get size of a file in bytes
Definition win32fswrapper.cc:259
static Util::String CreateTemporaryFilename(const Util::String &path)
create a temporary file name
Definition win32fswrapper.cc:470
static Util::String GetBinDirectory()
get path to the current bin directory (for bin: standard assign)
Definition win32fswrapper.cc:640
static Util::String GetTempDirectory()
get path to the current user's temp directory (for temp: standard assign)
Definition win32fswrapper.cc:624
@ Write
Definition filewatcher.h:47
[TODO: Describe Win32 subsystem]
Nebula's universal string class.
Definition string.h:50
int SizeT
Definition types.h:49
unsigned short ushort
Definition types.h:32