Mercurial > foo_out_sdl
comparison foosdk/sdk/pfc/filehandle.cpp @ 1:20d02a178406 default tip
*: check in everything else
yay
| author | Paper <paper@tflc.us> |
|---|---|
| date | Mon, 05 Jan 2026 02:15:46 -0500 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 0:e9bb126753e7 | 1:20d02a178406 |
|---|---|
| 1 #include "pfc-lite.h" | |
| 2 #include "filehandle.h" | |
| 3 | |
| 4 #ifndef _WIN32 | |
| 5 #include <unistd.h> | |
| 6 #endif | |
| 7 | |
| 8 namespace pfc { | |
| 9 void fileHandleClose( fileHandle_t h ) noexcept { | |
| 10 if (h == fileHandleInvalid) return; | |
| 11 #ifdef _WIN32 | |
| 12 CloseHandle( h ); | |
| 13 #else | |
| 14 close( h ); | |
| 15 #endif | |
| 16 } | |
| 17 | |
| 18 fileHandle_t fileHandleDup( fileHandle_t h ) { | |
| 19 #ifdef _WIN32 | |
| 20 auto proc = GetCurrentProcess(); | |
| 21 HANDLE out; | |
| 22 if (!DuplicateHandle ( proc, h, proc, &out, 0, FALSE, DUPLICATE_SAME_ACCESS )) return fileHandleInvalid; | |
| 23 return out; | |
| 24 #else | |
| 25 return dup( h ); | |
| 26 #endif | |
| 27 } | |
| 28 | |
| 29 void fileHandle::close() noexcept { | |
| 30 fileHandleClose( h ); | |
| 31 clear(); | |
| 32 } | |
| 33 | |
| 34 } |
