Merge commit 'f87fae7a25007a65c4907b534921747d19359532' as 'libs/physfs'
This commit is contained in:
commit
1211c74c9e
3
libs/physfs/.gitignore
vendored
Normal file
3
libs/physfs/.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
physfs
|
||||||
|
*.a
|
||||||
|
*.so
|
26
libs/physfs/LICENSE
Normal file
26
libs/physfs/LICENSE
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
Copyright (c) 2022 Stanaforth (@spindlebink). All rights reserved.
|
||||||
|
|
||||||
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
modification, are permitted provided that the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of source code must retain the above copyright notice, this
|
||||||
|
list of conditions and the following disclaimer.
|
||||||
|
|
||||||
|
2. Redistributions in binary form must reproduce the above copyright notice,
|
||||||
|
this list of conditions and the following disclaimer in the documentation
|
||||||
|
and/or other materials provided with the distribution.
|
||||||
|
|
||||||
|
3. Neither the name of the copyright holder nor the names of its
|
||||||
|
contributors may be used to endorse or promote products derived from
|
||||||
|
this software without specific prior written permission.
|
||||||
|
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||||
|
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||||
|
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||||
|
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
||||||
|
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
||||||
|
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||||
|
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
||||||
|
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
7
libs/physfs/README.md
Normal file
7
libs/physfs/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# PhysFS Odin
|
||||||
|
|
||||||
|
1-1 bindings to [PhysFS](https://icculus.org/physfs) in the [Odin programming language](https://odin-lang.org).
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
BSD 3-clause.
|
132
libs/physfs/physfs.odin
Normal file
132
libs/physfs/physfs.odin
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
package physfs
|
||||||
|
|
||||||
|
import "core:c"
|
||||||
|
|
||||||
|
when ODIN_OS == .Linux || ODIN_OS == .Darwin {
|
||||||
|
foreign import lib "libphysfs.a"
|
||||||
|
}
|
||||||
|
|
||||||
|
@(default_calling_convention="c", link_prefix="PHYSFS_")
|
||||||
|
foreign lib {
|
||||||
|
init :: proc(argv0: cstring) -> c.int ---
|
||||||
|
isInit :: proc() -> c.int ---
|
||||||
|
deinit :: proc() -> c.int ---
|
||||||
|
supportedArchiveTypes :: proc() -> [^]^ArchiveInfo ---
|
||||||
|
freeList :: proc(listVar: rawptr) ---
|
||||||
|
|
||||||
|
getLastError :: proc() -> cstring ---
|
||||||
|
getDirSeparator :: proc() -> cstring ---
|
||||||
|
permitSymbolicLinks :: proc(allow: c.int) ---
|
||||||
|
getCdRomDirs :: proc() -> [^]cstring ---
|
||||||
|
getBaseDir :: proc() -> cstring ---
|
||||||
|
getUserDir :: proc() -> cstring ---
|
||||||
|
getWriteDir :: proc() -> cstring ---
|
||||||
|
setWriteDir :: proc(newDir: cstring) -> c.int ---
|
||||||
|
addToSearchPath :: proc(newDir: cstring, appendToPath: c.int) -> c.int ---
|
||||||
|
removeFromSearchPath :: proc(oldDir: cstring) -> c.int ---
|
||||||
|
getSearchPath :: proc() -> [^]cstring ---
|
||||||
|
setSaneConfig :: proc(organization, appName, archiveExt: cstring, includedCdRoms, archivesFirst: c.int) -> c.int ---
|
||||||
|
|
||||||
|
mkdir :: proc(dirName: cstring) -> c.int ---
|
||||||
|
delete :: proc(filename: cstring) -> c.int ---
|
||||||
|
|
||||||
|
getRealDir :: proc(filename: cstring) -> cstring ---
|
||||||
|
getPrefDir :: proc(org, app: cstring) -> cstring ---
|
||||||
|
enumerateFiles :: proc(dir: cstring) -> [^]cstring ---
|
||||||
|
exists :: proc(fname: cstring) -> c.int ---
|
||||||
|
isDirectory :: proc(fname: cstring) -> c.int ---
|
||||||
|
isSymbolicLink :: proc(fname: cstring) -> c.int ---
|
||||||
|
getLastModTime :: proc(fname: cstring) -> sint64 ---
|
||||||
|
symbolicLinksPermitted :: proc() -> c.int ---
|
||||||
|
getLastErrorCode :: proc() -> ErrorCode ---
|
||||||
|
getErrorByCode :: proc(code: ErrorCode) -> cstring ---
|
||||||
|
setErrorCode :: proc(code: ErrorCode) ---
|
||||||
|
|
||||||
|
openWrite :: proc(filename: cstring) -> ^File ---
|
||||||
|
openAppend :: proc(filename: cstring) -> ^File ---
|
||||||
|
openRead :: proc(filename: cstring) -> ^File ---
|
||||||
|
|
||||||
|
close :: proc(handle: ^File) -> c.int ---
|
||||||
|
read :: proc(handle: ^File, buffer: rawptr, objSize, objCount: uint32) -> sint64 ---
|
||||||
|
write :: proc(handle: ^File, buffer: rawptr, objSize, objCount: uint32) -> sint64 ---
|
||||||
|
eof :: proc(handle: ^File) -> c.int ---
|
||||||
|
tell :: proc(handle: ^File) -> sint64 ---
|
||||||
|
seek :: proc(handle: ^File, pos: uint64) -> c.int ---
|
||||||
|
stat :: proc(fname: cstring, stat: ^Stat) -> c.int ---
|
||||||
|
fileLength :: proc(handle: ^File) -> sint64 ---
|
||||||
|
setBuffer :: proc(handle: ^File, bufsize: uint64) -> c.int ---
|
||||||
|
flush :: proc(handle: ^File) -> c.int ---
|
||||||
|
readBytes :: proc(handle: ^File, buffer: rawptr, len: uint64) -> sint64 ---
|
||||||
|
writeBytes :: proc(handle: ^File, buffer: rawptr, len: uint64) -> sint64 ---
|
||||||
|
|
||||||
|
registerArchiver :: proc(archiver: ^Archiver) -> c.int ---
|
||||||
|
deregisterArchiver :: proc(ext: cstring) -> c.int ---
|
||||||
|
|
||||||
|
setRoot :: proc(archive, subdir: cstring) -> c.int ---
|
||||||
|
setAllocator :: proc(allocator: ^Allocator) -> c.int ---
|
||||||
|
getAllocator :: proc() -> ^Allocator ---
|
||||||
|
|
||||||
|
mount :: proc(newDir, mountPoint: cstring, appendToPath: c.int) -> c.int ---
|
||||||
|
unmount :: proc(oldDir: cstring) -> c.int ---
|
||||||
|
mountIo :: proc(io: ^Io, newdir, mountPoint: cstring, appendToPath: c.int) -> c.int ---
|
||||||
|
mountMemory :: proc(buf: rawptr, len: uint64, del: proc "c"(rawptr), newDir, mountPoint: cstring, appendToPath: c.int) -> c.int ---
|
||||||
|
mountHandle :: proc(file: ^File, newDir, mountPoint: cstring, appendToPath: c.int) -> c.int ---
|
||||||
|
|
||||||
|
getMountPoint :: proc(dir: cstring) -> cstring ---
|
||||||
|
getCdRomDirsCallback :: proc(c: StringCallback, d: rawptr) ---
|
||||||
|
getSearchPathCallback :: proc(c: StringCallback, d: rawptr) ---
|
||||||
|
enumerateFilesCallback :: proc(dir: cstring, c: EnumFilesCallback, d: rawptr) ---
|
||||||
|
enumerate :: proc(dir: cstring, callback: EnumerateCallback, d: rawptr) -> c.int ---
|
||||||
|
|
||||||
|
swapSLE16 :: proc(val: sint16) -> sint16 ---
|
||||||
|
swapULE16 :: proc(val: uint16) -> uint16 ---
|
||||||
|
swapLE32 :: proc(val: sint32) -> sint32 ---
|
||||||
|
swapULE32 :: proc(val: uint32) -> uint32 ---
|
||||||
|
swapSLE64 :: proc(val: sint64) -> sint64 ---
|
||||||
|
swapULE64 :: proc(val: uint64) -> uint64 ---
|
||||||
|
swapSBE16 :: proc(val: sint16) -> sint16 ---
|
||||||
|
swapUBE16 :: proc(val: uint16) -> uint16 ---
|
||||||
|
swapBE32 :: proc(val: sint32) -> sint32 ---
|
||||||
|
swapUBE32 :: proc(val: uint32) -> uint32 ---
|
||||||
|
swapSBE64 :: proc(val: sint64) -> sint64 ---
|
||||||
|
swapUBE64 :: proc(val: uint64) -> uint64 ---
|
||||||
|
|
||||||
|
readSLE16 :: proc(file: ^File, val: ^sint16) -> c.int ---
|
||||||
|
readULE16 :: proc(file: ^File, val: ^uint16) -> c.int ---
|
||||||
|
readSLE32 :: proc(file: ^File, val: ^sint32) -> c.int ---
|
||||||
|
readULE32 :: proc(file: ^File, val: ^uint32) -> c.int ---
|
||||||
|
readSLE64 :: proc(file: ^File, val: ^sint64) -> c.int ---
|
||||||
|
readULE64 :: proc(file: ^File, val: ^uint64) -> c.int ---
|
||||||
|
readSBE16 :: proc(file: ^File, val: ^sint16) -> c.int ---
|
||||||
|
readUBE16 :: proc(file: ^File, val: ^uint16) -> c.int ---
|
||||||
|
readSBE32 :: proc(file: ^File, val: ^sint32) -> c.int ---
|
||||||
|
readUBE32 :: proc(file: ^File, val: ^uint32) -> c.int ---
|
||||||
|
readSBE64 :: proc(file: ^File, val: ^sint64) -> c.int ---
|
||||||
|
readUBE64 :: proc(file: ^File, val: ^uint64) -> c.int ---
|
||||||
|
|
||||||
|
writeSLE16 :: proc(file: ^File, val: sint16) -> c.int ---
|
||||||
|
writeULE16 :: proc(file: ^File, val: uint16) -> c.int ---
|
||||||
|
writeSLE32 :: proc(file: ^File, val: sint32) -> c.int ---
|
||||||
|
writeULE32 :: proc(file: ^File, val: uint32) -> c.int ---
|
||||||
|
writeSLE64 :: proc(file: ^File, val: sint64) -> c.int ---
|
||||||
|
writeULE64 :: proc(file: ^File, val: uint64) -> c.int ---
|
||||||
|
writeSBE16 :: proc(file: ^File, val: sint16) -> c.int ---
|
||||||
|
writeUBE16 :: proc(file: ^File, val: uint16) -> c.int ---
|
||||||
|
writeSBE32 :: proc(file: ^File, val: sint32) -> c.int ---
|
||||||
|
writeUBE32 :: proc(file: ^File, val: uint32) -> c.int ---
|
||||||
|
writeSBE64 :: proc(file: ^File, val: sint64) -> c.int ---
|
||||||
|
writeUBE64 :: proc(file: ^File, val: uint64) -> c.int ---
|
||||||
|
|
||||||
|
utf8FromUcs4 :: proc(src: ^uint32, dst: cstring, len: uint64) ---
|
||||||
|
utf8ToUcs4 :: proc(src: cstring, dst: ^uint32, len: uint64) ---
|
||||||
|
utf8FromUcs2 :: proc(src: ^uint16, dst: cstring, len: uint64) ---
|
||||||
|
utf8ToUcs2 :: proc(src: cstring, dst: ^uint16, len: uint64) ---
|
||||||
|
utf8FromLatin1 :: proc(src, dst: cstring, len: uint64) ---
|
||||||
|
utf8FromUtf16 :: proc(src: ^uint16, dst: cstring, len: uint64) ---
|
||||||
|
utf8ToUtf16 :: proc(src: cstring, dst: ^uint16, len: uint64) ---
|
||||||
|
|
||||||
|
caseFold :: proc(from: uint32, to: ^uint32) -> c.int ---
|
||||||
|
utf8stricmp :: proc(str1, str2: cstring) -> c.int ---
|
||||||
|
utf16stricmp :: proc(str1, str2: cstring) -> c.int ---
|
||||||
|
ucs4stricmp :: proc(str1, str2: ^uint32) -> c.int ---
|
||||||
|
}
|
121
libs/physfs/types.odin
Normal file
121
libs/physfs/types.odin
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
package physfs
|
||||||
|
|
||||||
|
import "core:c"
|
||||||
|
|
||||||
|
uint8 :: c.uchar
|
||||||
|
sint8 :: c.char
|
||||||
|
uint16 :: c.ushort
|
||||||
|
sint16 :: c.short
|
||||||
|
uint32 :: c.uint
|
||||||
|
sint32 :: c.int
|
||||||
|
uint64 :: c.ulonglong
|
||||||
|
sint64 :: c.longlong
|
||||||
|
|
||||||
|
File :: struct {
|
||||||
|
opaque: rawptr,
|
||||||
|
}
|
||||||
|
|
||||||
|
ArchiveInfo :: struct {
|
||||||
|
extension, description, author, url: cstring,
|
||||||
|
supportsSymlinks: c.int,
|
||||||
|
}
|
||||||
|
|
||||||
|
Version :: struct {
|
||||||
|
major, minor, patch: uint8,
|
||||||
|
}
|
||||||
|
|
||||||
|
AndroidInit :: struct {
|
||||||
|
jnienv, ctx: rawptr,
|
||||||
|
}
|
||||||
|
|
||||||
|
Allocator :: struct {
|
||||||
|
Init: proc "c" () -> c.int,
|
||||||
|
Deinit: proc "c" (),
|
||||||
|
Malloc: proc "c" (uint64) -> rawptr,
|
||||||
|
Realloc: proc "c" (rawptr, uint64) -> rawptr,
|
||||||
|
Free: proc "c" (rawptr),
|
||||||
|
}
|
||||||
|
|
||||||
|
StringCallback :: proc "c" (rawptr, cstring)
|
||||||
|
EnumFilesCallback :: proc "c" (rawptr, cstring, cstring)
|
||||||
|
|
||||||
|
EnumerateCallbackResult :: enum c.int {
|
||||||
|
ERROR = -1,
|
||||||
|
STOP = 0,
|
||||||
|
OK = 1,
|
||||||
|
}
|
||||||
|
|
||||||
|
EnumerateCallback :: proc "c" (rawptr, cstring, cstring) -> EnumerateCallbackResult
|
||||||
|
|
||||||
|
FileType :: enum c.int {
|
||||||
|
REGULAR,
|
||||||
|
DIRECTORY,
|
||||||
|
SYMLINK,
|
||||||
|
OTHER,
|
||||||
|
}
|
||||||
|
|
||||||
|
Stat :: struct {
|
||||||
|
filesize, modtime, createtime, accesstime: sint64,
|
||||||
|
filetype: FileType,
|
||||||
|
readonly: c.int,
|
||||||
|
}
|
||||||
|
|
||||||
|
Io :: struct {
|
||||||
|
version: uint32,
|
||||||
|
opaque: rawptr,
|
||||||
|
read: proc "c" (^Io, rawptr, uint64) -> sint64,
|
||||||
|
write: proc "c" (^Io, rawptr, uint64) -> sint64,
|
||||||
|
seek: proc "c" (^Io, uint64) -> c.int,
|
||||||
|
tell: proc "c" (^Io) -> sint64,
|
||||||
|
length: proc "c" (^Io) -> sint64,
|
||||||
|
duplicate: proc "c" (^Io) -> ^Io,
|
||||||
|
flush: proc "c" (^Io) -> c.int,
|
||||||
|
destroy: proc "c" (^Io),
|
||||||
|
}
|
||||||
|
|
||||||
|
ErrorCode :: enum c.int {
|
||||||
|
OK,
|
||||||
|
OTHER_ERROR,
|
||||||
|
OUT_OF_MEMORY,
|
||||||
|
NOT_INITIALIZED,
|
||||||
|
IS_INITIALIZED,
|
||||||
|
ARGV0_IS_NULL,
|
||||||
|
UNSUPPORTED,
|
||||||
|
PAST_EOF,
|
||||||
|
FILES_STILL_OPEN,
|
||||||
|
INVALID_ARGUMENT,
|
||||||
|
NOT_MOUNTED,
|
||||||
|
NOT_FOUND,
|
||||||
|
SYMLINK_FORBIDDEN,
|
||||||
|
NO_WRITE_DIR,
|
||||||
|
OPEN_FOR_READING,
|
||||||
|
OPEN_FOR_WRITING,
|
||||||
|
NOT_A_FILE,
|
||||||
|
READ_ONLY,
|
||||||
|
CORRUPT,
|
||||||
|
SYMLINK_LOOP,
|
||||||
|
IO,
|
||||||
|
PERMISSION,
|
||||||
|
NO_SPACE,
|
||||||
|
BAD_FILENAME,
|
||||||
|
BUSY,
|
||||||
|
DIR_NOT_EMPTY,
|
||||||
|
OS_ERROR,
|
||||||
|
DUPLICATE,
|
||||||
|
BAD_PASSWORD,
|
||||||
|
APP_CALLBACK,
|
||||||
|
}
|
||||||
|
|
||||||
|
Archiver :: struct {
|
||||||
|
version: uint32,
|
||||||
|
info: ArchiveInfo,
|
||||||
|
openArchive: proc "c" (^Io, cstring, c.int, ^c.int) -> rawptr,
|
||||||
|
enumerate: proc "c" (rawptr, cstring, EnumerateCallback, cstring, rawptr) -> EnumerateCallbackResult,
|
||||||
|
openRead: proc "c" (rawptr, cstring) -> ^Io,
|
||||||
|
openWrite: proc "c" (rawptr, cstring) -> ^Io,
|
||||||
|
openAppend: proc "c" (rawptr, cstring) -> ^Io,
|
||||||
|
remove: proc "c" (rawptr, cstring) -> c.int,
|
||||||
|
mkdir: proc "c" (rawptr, cstring) -> c.int,
|
||||||
|
stat: proc "c" (rawptr, cstring, ^Stat) -> c.int,
|
||||||
|
closeArchive: proc "c" (rawptr),
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user