Nebula
Loading...
Searching...
No Matches
posixfswrapper.h
Go to the documentation of this file.
1#pragma once
2#ifndef POSIX_POSIXFSWRAPPER_H
3#define POSIX_POSIXFSWRAPPER_H
4//------------------------------------------------------------------------------
14#include "core/types.h"
15#include "util/string.h"
16#include "util/array.h"
17#include "io/stream.h"
18#include "io/filetime.h"
19
20//------------------------------------------------------------------------------
21namespace Posix
22{
24{
25public:
26 typedef FILE * Handle;
27
29 static Handle OpenFile(const Util::String& path, IO::Stream::AccessMode accessMode, IO::Stream::AccessPattern accessPattern);
31 static void CloseFile(Handle h);
33 static void Write(Handle h, const void* buf, IO::Stream::Size numBytes);
35 static IO::Stream::Size Read(Handle h, void* buf, IO::Stream::Size numBytes);
37 static char* Map(Handle h, IO::Stream::AccessMode accessMode, Handle& mappedHandle);
39 static void Unmap(Handle mapHandle, char* buf);
41 static void Seek(Handle h, IO::Stream::Offset offset, IO::Stream::SeekOrigin orig);
45 static void Flush(Handle h);
47 static bool Eof(Handle h);
51 static void SetReadOnly(const Util::String& path, bool readOnly);
53 static bool IsReadOnly(const Util::String& path);
55 static bool IsLocked(const Util::String& path);
57 static bool DeleteFile(const Util::String& path);
59 static bool ReplaceFile(const Util::String& source, const Util::String& target);
61 static bool DeleteDirectory(const Util::String& path);
63 static bool FileExists(const Util::String& path);
65 static bool DirectoryExists(const Util::String& path);
67 static void SetFileWriteTime(const Util::String& path, IO::FileTime fileTime);
69 static IO::FileTime GetFileWriteTime(const Util::String& path);
71 static bool CreateDirectory(const Util::String& path);
75 static Util::Array<Util::String> ListFiles(const Util::String& dirPath, const Util::String& pattern);
77 static Util::Array<Util::String> ListDirectories(const Util::String& dirPath, const Util::String& pattern);
87 static bool IsDeviceName(const Util::String& str);
88};
89
90}; // namespace Posix
91//------------------------------------------------------------------------------
92#endif
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
Internal filesystem wrapper for Posix.
Definition posixfswrapper.h:24
static bool CreateDirectory(const Util::String &path)
create a directory
Definition posixfswrapper.cc:387
static void Flush(Handle h)
flush a file
Definition posixfswrapper.cc:187
static void Seek(Handle h, IO::Stream::Offset offset, IO::Stream::SeekOrigin orig)
seek in a file
Definition posixfswrapper.cc:148
static char * Map(Handle h, IO::Stream::AccessMode accessMode, Handle &mappedHandle)
map file to virtual memory
Definition posixfswrapper.cc:118
static IO::Stream::Position Tell(Handle h)
get position in file
Definition posixfswrapper.cc:176
static IO::FileTime GetFileWriteTime(const Util::String &path)
get the last write-access time stamp of a file
Definition posixfswrapper.cc:368
static Util::String CreateTemporaryFilename(const Util::String &path)
create a temporary file name
Definition posixfswrapper.cc:397
static IO::Stream::Size Read(Handle h, void *buf, IO::Stream::Size numBytes)
read from a file
Definition posixfswrapper.cc:98
static void SetFileWriteTime(const Util::String &path, IO::FileTime fileTime)
set the write-access time stamp of a file
Definition posixfswrapper.cc:358
static Util::String GetUserDirectory()
get path to the current user's home directory (for user: standard assign)
Definition posixfswrapper.cc:498
static Util::Array< Util::String > ListDirectories(const Util::String &dirPath, const Util::String &pattern)
list all subdirectories in a directory
Definition posixfswrapper.cc:450
static void SetReadOnly(const Util::String &path, bool readOnly)
set read-only status of a file
Definition posixfswrapper.cc:227
static Handle OpenFile(const Util::String &path, IO::Stream::AccessMode accessMode, IO::Stream::AccessPattern accessPattern)
open a file
Definition posixfswrapper.cc:39
static bool IsDeviceName(const Util::String &str)
return true when the string is a device name (e.g. "C:")
Definition posixfswrapper.cc:598
static bool IsReadOnly(const Util::String &path)
get read-only status of a file
Definition posixfswrapper.cc:253
static bool DirectoryExists(const Util::String &path)
return true if a directory exists
Definition posixfswrapper.cc:341
static Util::String GetTempDirectory()
get path to the current user's temp directory (for temp: standard assign)
Definition posixfswrapper.cc:511
static bool DeleteFile(const Util::String &path)
delete a file
Definition posixfswrapper.cc:293
FILE * Handle
Definition posixfswrapper.h:26
static bool Eof(Handle h)
return true if at end-of-file
Definition posixfswrapper.cc:198
static bool ReplaceFile(const Util::String &source, const Util::String &target)
rename a file
Definition posixfswrapper.cc:303
static void Unmap(Handle mapHandle, char *buf)
unmap file
Definition posixfswrapper.cc:137
static bool FileExists(const Util::String &path)
return true if a file exists
Definition posixfswrapper.cc:324
static void CloseFile(Handle h)
close a file
Definition posixfswrapper.cc:70
static bool DeleteDirectory(const Util::String &path)
delete an empty directory
Definition posixfswrapper.cc:313
static Util::Array< Util::String > ListFiles(const Util::String &dirPath, const Util::String &pattern)
list all files in a directory
Definition posixfswrapper.cc:411
static IO::Stream::Size GetFileSize(Handle h)
get size of a file in bytes
Definition posixfswrapper.cc:214
static Util::String GetBinDirectory()
get path to the current bin directory (for bin: standard assign)
Definition posixfswrapper.cc:522
static Util::String GetHomeDirectory()
get path to the current application directory (for home: standard assign)
Definition posixfswrapper.cc:554
static bool IsLocked(const Util::String &path)
get locked status of file
Definition posixfswrapper.cc:278
Nebula's dynamic array class.
Definition array.h:60
@ Write
Definition filewatcher.h:47
Posix implemention of a read-many write-few lock.
Definition posixsysfunc.cc:21
Nebula's universal string class.
Definition string.h:50