| 54 | // Local functions - base file support |
| 55 | |
| 56 | static bool BaseFile_Create(TFileStream * pStream) |
| 57 | { |
| 58 | #ifdef CASCLIB_PLATFORM_WINDOWS |
| 59 | { |
| 60 | DWORD dwWriteShare = (pStream->dwFlags & STREAM_FLAG_WRITE_SHARE) ? FILE_SHARE_WRITE : 0; |
| 61 | |
| 62 | pStream->Base.File.hFile = CreateFile(pStream->szFileName, |
| 63 | GENERIC_READ | GENERIC_WRITE, |
| 64 | dwWriteShare | FILE_SHARE_READ, |
| 65 | NULL, |
| 66 | CREATE_ALWAYS, |
| 67 | 0, |
| 68 | NULL); |
| 69 | if(pStream->Base.File.hFile == INVALID_HANDLE_VALUE) |
| 70 | return false; |
| 71 | } |
| 72 | #endif |
| 73 | |
| 74 | #if defined(CASCLIB_PLATFORM_MAC) || defined(CASCLIB_PLATFORM_LINUX) |
| 75 | { |
| 76 | intptr_t handle; |
| 77 | |
| 78 | handle = open(pStream->szFileName, O_RDWR | O_CREAT | O_TRUNC | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 79 | if(handle == -1) |
| 80 | { |
| 81 | pStream->Base.File.hFile = INVALID_HANDLE_VALUE; |
| 82 | SetCascError(errno); |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | pStream->Base.File.hFile = (HANDLE)handle; |
| 87 | } |
| 88 | #endif |
| 89 | |
| 90 | // Reset the file size and position |
| 91 | pStream->Base.File.FileSize = 0; |
| 92 | pStream->Base.File.FilePos = 0; |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | static bool BaseFile_Open(TFileStream * pStream, LPCTSTR szFileName, DWORD dwStreamFlags) |
| 97 | { |
no test coverage detected