| 2356 | */ |
| 2357 | |
| 2358 | TFileStream * FileStream_CreateFile( |
| 2359 | const TCHAR * szFileName, |
| 2360 | DWORD dwStreamFlags) |
| 2361 | { |
| 2362 | TFileStream * pStream; |
| 2363 | |
| 2364 | // We only support creation of flat, local file |
| 2365 | if((dwStreamFlags & (STREAM_PROVIDERS_MASK)) != (STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE)) |
| 2366 | { |
| 2367 | SetLastError(ERROR_NOT_SUPPORTED); |
| 2368 | return NULL; |
| 2369 | } |
| 2370 | |
| 2371 | // Allocate file stream structure for flat stream |
| 2372 | pStream = AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); |
| 2373 | if(pStream != NULL) |
| 2374 | { |
| 2375 | // Attempt to create the disk file |
| 2376 | if(BaseFile_Create(pStream)) |
| 2377 | { |
| 2378 | // Fill the stream provider functions |
| 2379 | pStream->StreamRead = pStream->BaseRead; |
| 2380 | pStream->StreamWrite = pStream->BaseWrite; |
| 2381 | pStream->StreamResize = pStream->BaseResize; |
| 2382 | pStream->StreamGetSize = pStream->BaseGetSize; |
| 2383 | pStream->StreamGetPos = pStream->BaseGetPos; |
| 2384 | pStream->StreamClose = pStream->BaseClose; |
| 2385 | return pStream; |
| 2386 | } |
| 2387 | |
| 2388 | // File create failed, delete the stream |
| 2389 | STORM_FREE(pStream); |
| 2390 | pStream = NULL; |
| 2391 | } |
| 2392 | |
| 2393 | // Return the stream |
| 2394 | return pStream; |
| 2395 | } |
| 2396 | |
| 2397 | /** |
| 2398 | * This function opens an existing file for read or read-write access |
no test coverage detected