58 class File :
public AddonClass
62 inline File(
const String& filepath,
const char* mode = NULL) : file(
new XFILE::CFile())
64 DelayedCallGuard dg(languageHook);
65 if (mode && strncmp(mode,
"w", 1) == 0)
66 file->OpenForWrite(filepath,
true);
68 file->Open(filepath, XFILE::READ_NO_CACHE);
71 inline ~File()
override {
delete file; }
73#if !defined(DOXYGEN_SHOULD_USE_THIS)
74 inline File* __enter__() {
return this; }
75 inline void __exit__() {
close(); }
78#ifdef DOXYGEN_SHOULD_USE_THIS
110 inline String
read(
unsigned long numBytes = 0)
112 XbmcCommons::Buffer b =
readBytes(numBytes);
113 return b.getString(numBytes == 0 ? b.remaining() : std::min((
unsigned long)b.remaining(),numBytes));
117#ifdef DOXYGEN_SHOULD_USE_THIS
149 XbmcCommons::Buffer
readBytes(
unsigned long numBytes = 0);
152#ifdef DOXYGEN_SHOULD_USE_THIS
183 bool write(XbmcCommons::Buffer& buffer);
186#ifdef DOXYGEN_SHOULD_USE_THIS
216 inline long long size() { DelayedCallGuard dg(languageHook);
return file->GetLength(); }
219#ifdef DOXYGEN_SHOULD_USE_THIS
252 inline long long seek(
long long seekBytes,
int iWhence = SEEK_SET) { DelayedCallGuard dg(languageHook);
return file->Seek(seekBytes,iWhence); }
255#ifdef DOXYGEN_SHOULD_USE_THIS
286 inline long long tell() { DelayedCallGuard dg(languageHook);
return file->GetPosition(); }
289#ifdef DOXYGEN_SHOULD_USE_THIS
316 inline void close() { DelayedCallGuard dg(languageHook); file->Close(); }
320 inline const XFILE::CFile* getFile()
const {
return file; }