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 IO::Stream::Size GetFileSize(const Util::String& path);
53 static bool GetIOInfo(const IO::URI& uri, IO::IOStat& outInfo);
55 static void SetReadOnly(const Util::String& path, bool readOnly);
57 static bool IsReadOnly(const Util::String& path);
59 static bool IsLocked(const Util::String& path);
61 static bool DeleteFile(const Util::String& path);
63 static bool ReplaceFile(const Util::String& source, const Util::String& target);
65 static bool DeleteDirectory(const Util::String& path);
67 static bool FileExists(const Util::String& path);
69 static bool DirectoryExists(const Util::String& path);
71 static void SetFileWriteTime(const Util::String& path, IO::FileTime fileTime);
73 static IO::FileTime GetFileWriteTime(const Util::String& path);
75 static bool CreateDirectory(const Util::String& path);
79 static Util::Array<Util::String> ListFiles(const Util::String& dirPath, const Util::String& pattern);
81 static Util::Array<Util::String> ListDirectories(const Util::String& dirPath, const Util::String& pattern);
91 static bool IsDeviceName(const Util::String& str);
92};
93
94}; // namespace Posix
95//------------------------------------------------------------------------------
96#endif
SeekOrigin
seek origins
Definition stream.h:54
int64_t Position
typedefs
Definition stream.h:32
int64_t Size
Definition stream.h:34
AccessMode
access modes
Definition stream.h:38
int64_t Offset
Definition stream.h:33
AccessPattern
access prefered pattern
Definition stream.h:47
An URI object can split a Uniform Resource Identifier string into its components or build a string fr...
Definition uri.h:67
Internal filesystem wrapper for Posix.
Definition posixfswrapper.h:24
static bool CreateDirectory(const Util::String &path)
create a directory
Definition posixfswrapper.cc:430
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
FILE * Handle
Definition posixfswrapper.h:26
static IO::FileTime GetFileWriteTime(const Util::String &path)
get the last write-access time stamp of a file
Definition posixfswrapper.cc:411
static Util::String CreateTemporaryFilename(const Util::String &path)
create a temporary file name
Definition posixfswrapper.cc:440
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:401
static Util::String GetUserDirectory()
get path to the current user's home directory (for user: standard assign)
Definition posixfswrapper.cc:542
static Util::Array< Util::String > ListDirectories(const Util::String &dirPath, const Util::String &pattern)
list all subdirectories in a directory
Definition posixfswrapper.cc:494
static void SetReadOnly(const Util::String &path, bool readOnly)
set read-only status of a file
Definition posixfswrapper.cc:270
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:648
static bool IsReadOnly(const Util::String &path)
get read-only status of a file
Definition posixfswrapper.cc:296
static bool DirectoryExists(const Util::String &path)
return true if a directory exists
Definition posixfswrapper.cc:384
static Util::String GetTempDirectory()
get path to the current user's temp directory (for temp: standard assign)
Definition posixfswrapper.cc:555
static bool DeleteFile(const Util::String &path)
delete a file
Definition posixfswrapper.cc:336
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:346
static bool GetIOInfo(const IO::URI &uri, IO::IOStat &outInfo)
get file/folder io info via stat
Definition posixfswrapper.cc:245
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:367
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:356
static Util::Array< Util::String > ListFiles(const Util::String &dirPath, const Util::String &pattern)
list all files in a directory
Definition posixfswrapper.cc:454
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:566
static Util::String GetHomeDirectory()
get path to the current application directory (for home: standard assign)
Definition posixfswrapper.cc:598
static bool IsLocked(const Util::String &path)
get locked status of file
Definition posixfswrapper.cc:321
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
Definition filetime.h:41
Nebula's universal string class.
Definition String.cs:8