mirror of
https://github.com/mackron/miniaudio.git
synced 2026-04-27 10:44:02 +02:00
Update fs.
This commit is contained in:
Vendored
+10
-10
@@ -11,14 +11,14 @@
|
|||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h> /* <-- Just can't get away from this darn thing... Needed for mutexes and file iteration. */
|
#include <windows.h> /* <-- Just can't get away from this darn thing... Needed for mutexes and file iteration. */
|
||||||
|
|
||||||
static int fs_result_from_GetLastError(DWORD error)
|
static fs_result fs_result_from_GetLastError(DWORD error)
|
||||||
{
|
{
|
||||||
switch (error)
|
switch (error)
|
||||||
{
|
{
|
||||||
case ERROR_SUCCESS: return FS_SUCCESS;
|
case ERROR_SUCCESS: return FS_SUCCESS;
|
||||||
case ERROR_NOT_ENOUGH_MEMORY: return ENOMEM;
|
case ERROR_NOT_ENOUGH_MEMORY: return FS_OUT_OF_MEMORY;
|
||||||
case ERROR_SEM_TIMEOUT: return ETIMEDOUT;
|
case ERROR_BUSY: return FS_BUSY;
|
||||||
case ERROR_BUSY: return EBUSY;
|
case ERROR_SEM_TIMEOUT: return FS_TIMEOUT;
|
||||||
default: break;
|
default: break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1376,9 +1376,11 @@ static fs_result fs_file_duplicate_proxy(fs_file* pFile, fs_file* pDuplicatedFil
|
|||||||
|
|
||||||
/* Increment the reference count of the opened archive if necessary. */
|
/* Increment the reference count of the opened archive if necessary. */
|
||||||
if (fs_file_proxy_get_unref_archive_on_close(pFile)) {
|
if (fs_file_proxy_get_unref_archive_on_close(pFile)) {
|
||||||
|
fs* pOwnerFS;
|
||||||
|
|
||||||
fs_file_proxy_set_unref_archive_on_close(pDuplicatedFile, FS_TRUE);
|
fs_file_proxy_set_unref_archive_on_close(pDuplicatedFile, FS_TRUE);
|
||||||
|
|
||||||
fs* pOwnerFS = fs_proxy_get_owner_fs(pFS);
|
pOwnerFS = fs_proxy_get_owner_fs(pFS);
|
||||||
if (pOwnerFS != NULL) {
|
if (pOwnerFS != NULL) {
|
||||||
fs_increment_opened_archive_ref_count(pOwnerFS, pFS);
|
fs_increment_opened_archive_ref_count(pOwnerFS, pFS);
|
||||||
}
|
}
|
||||||
@@ -4517,7 +4519,7 @@ static fs_uint64 fs_FILETIME_to_unix(const FILETIME* pFT)
|
|||||||
li.HighPart = pFT->dwHighDateTime;
|
li.HighPart = pFT->dwHighDateTime;
|
||||||
li.LowPart = pFT->dwLowDateTime;
|
li.LowPart = pFT->dwLowDateTime;
|
||||||
|
|
||||||
return (fs_uint64)(li.QuadPart / 10000000ULL - 11644473600ULL); /* Convert from Windows epoch to Unix epoch. */
|
return (fs_uint64)(li.QuadPart / 10000000UL - 11644473600UL); /* Convert from Windows epoch to Unix epoch. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static fs_file_info fs_file_info_from_WIN32_FIND_DATAW(const WIN32_FIND_DATAW* pFD)
|
static fs_file_info fs_file_info_from_WIN32_FIND_DATAW(const WIN32_FIND_DATAW* pFD)
|
||||||
@@ -5048,7 +5050,7 @@ FS_API fs_result fs_file_duplicate_stdio(fs_file* pFile, fs_file* pDuplicatedFil
|
|||||||
return fs_result_from_errno(GetLastError());
|
return fs_result_from_errno(GetLastError());
|
||||||
}
|
}
|
||||||
|
|
||||||
fdDuplicate = _open_osfhandle((intptr_t)hFileDuplicate, _O_RDONLY);
|
fdDuplicate = _open_osfhandle((fs_intptr)hFileDuplicate, _O_RDONLY);
|
||||||
if (fdDuplicate == -1) {
|
if (fdDuplicate == -1) {
|
||||||
CloseHandle(hFileDuplicate);
|
CloseHandle(hFileDuplicate);
|
||||||
return fs_result_from_errno(errno);
|
return fs_result_from_errno(errno);
|
||||||
@@ -6003,8 +6005,6 @@ FS_API int fs_path_normalize(char* pDst, size_t dstCap, const char* pPath, size_
|
|||||||
|
|
||||||
|
|
||||||
/* BEG fs_memory_stream.c */
|
/* BEG fs_memory_stream.c */
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
static fs_result fs_memory_stream_read_internal(fs_stream* pStream, void* pDst, size_t bytesToRead, size_t* pBytesRead)
|
static fs_result fs_memory_stream_read_internal(fs_stream* pStream, void* pDst, size_t bytesToRead, size_t* pBytesRead)
|
||||||
{
|
{
|
||||||
return fs_memory_stream_read((fs_memory_stream*)pStream, pDst, bytesToRead, pBytesRead);
|
return fs_memory_stream_read((fs_memory_stream*)pStream, pDst, bytesToRead, pBytesRead);
|
||||||
@@ -6030,7 +6030,7 @@ static fs_result fs_memory_stream_tell_internal(fs_stream* pStream, fs_int64* pC
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cursor > INT64_MAX) { /* <-- INT64_MAX may not be defined on some compilers. Need to check this. Can easily define this ourselves. */
|
if (cursor > FS_INT64_MAX) { /* <-- INT64_MAX may not be defined on some compilers. Need to check this. Can easily define this ourselves. */
|
||||||
return FS_ERROR;
|
return FS_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Vendored
+7
@@ -580,8 +580,10 @@ extern "C" {
|
|||||||
|
|
||||||
#if FS_SIZEOF_PTR == 8
|
#if FS_SIZEOF_PTR == 8
|
||||||
typedef unsigned long long fs_uintptr;
|
typedef unsigned long long fs_uintptr;
|
||||||
|
typedef long long fs_intptr;
|
||||||
#else
|
#else
|
||||||
typedef unsigned int fs_uintptr;
|
typedef unsigned int fs_uintptr;
|
||||||
|
typedef int fs_intptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef unsigned char fs_bool8;
|
typedef unsigned char fs_bool8;
|
||||||
@@ -590,6 +592,9 @@ typedef unsigned int fs_bool32;
|
|||||||
#define FS_FALSE 0
|
#define FS_FALSE 0
|
||||||
|
|
||||||
|
|
||||||
|
#define FS_INT64_MAX ((fs_int64)(((fs_uint64)0x7FFFFFFF << 32) | 0xFFFFFFFF))
|
||||||
|
|
||||||
|
|
||||||
#ifndef FS_API
|
#ifndef FS_API
|
||||||
#define FS_API
|
#define FS_API
|
||||||
#endif
|
#endif
|
||||||
@@ -659,8 +664,10 @@ typedef enum fs_result
|
|||||||
FS_IS_DIRECTORY = -15,
|
FS_IS_DIRECTORY = -15,
|
||||||
FS_DIRECTORY_NOT_EMPTY = -16,
|
FS_DIRECTORY_NOT_EMPTY = -16,
|
||||||
FS_AT_END = -17,
|
FS_AT_END = -17,
|
||||||
|
FS_BUSY = -19,
|
||||||
FS_BAD_SEEK = -25,
|
FS_BAD_SEEK = -25,
|
||||||
FS_NOT_IMPLEMENTED = -29,
|
FS_NOT_IMPLEMENTED = -29,
|
||||||
|
FS_TIMEOUT = -34,
|
||||||
FS_CHECKSUM_MISMATCH = -100,
|
FS_CHECKSUM_MISMATCH = -100,
|
||||||
FS_NO_BACKEND = -101
|
FS_NO_BACKEND = -101
|
||||||
} fs_result;
|
} fs_result;
|
||||||
|
|||||||
Reference in New Issue
Block a user