-
Notifications
You must be signed in to change notification settings - Fork 0
/
CABALPortRocket.cxx
49 lines (40 loc) · 1.41 KB
/
CABALPortRocket.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "CABALPortRocket.hxx"
#include <Rocket/Core/String.h>
#include <Rocket/Core/FileInterface.h>
#include "CABAL.hxx"
Rocket::Core::FileHandle ShellFileInterface::Open(const Rocket::Core::String& path) {
return (Rocket::Core::FileHandle) CABAL::open(path.CString(), CABAL::READ); }
void ShellFileInterface::Close(Rocket::Core::FileHandle file) {
CABAL::FileHandle *h = reinterpret_cast<CABAL::FileHandle *>(file);
h->close();
}
size_t ShellFileInterface::Read(void* buffer, size_t size, Rocket::Core::FileHandle file) {
CABAL::FileHandle *h = reinterpret_cast<CABAL::FileHandle *>(file);
return static_cast<size_t>(h->read(buffer, size));
}
bool ShellFileInterface::Seek(Rocket::Core::FileHandle file, long offset, int origin) {
CABAL::SeekOrigin oric;
switch (origin) {
case SEEK_SET:
oric = CABAL::BEGINNING;
break;
case SEEK_CUR:
oric = CABAL::CURRENT;
break;
case SEEK_END:
oric = CABAL::END;
break;
default:
return false;
}
CABAL::FileHandle *h = reinterpret_cast<CABAL::FileHandle *>(file);
return (h->seek(offset, oric) != -1);
}
size_t ShellFileInterface::Tell(Rocket::Core::FileHandle file) {
CABAL::FileHandle *h = reinterpret_cast<CABAL::FileHandle *>(file);
return static_cast<size_t>(h->tell());
}
size_t ShellFileInterface::Length(Rocket::Core::FileHandle file) {
CABAL::FileHandle *h = reinterpret_cast<CABAL::FileHandle *>(file);
return static_cast<size_t>(h->size());
}