| 2386 | */ |
| 2387 | |
| 2388 | TFileStream * FileStream_CreateFile( |
| 2389 | LPCTSTR szFileName, |
| 2390 | DWORD dwStreamFlags) |
| 2391 | { |
| 2392 | TFileStream * pStream; |
| 2393 | |
| 2394 | // We only support creation of flat, local file |
| 2395 | if((dwStreamFlags & (STREAM_PROVIDERS_MASK)) != (STREAM_PROVIDER_FLAT | BASE_PROVIDER_FILE)) |
| 2396 | { |
| 2397 | SetCascError(ERROR_NOT_SUPPORTED); |
| 2398 | return NULL; |
| 2399 | } |
| 2400 | |
| 2401 | // Allocate file stream structure for flat stream |
| 2402 | pStream = AllocateFileStream(szFileName, sizeof(TBlockStream), dwStreamFlags); |
| 2403 | if(pStream != NULL) |
| 2404 | { |
| 2405 | // Attempt to create the disk file |
| 2406 | if(BaseFile_Create(pStream)) |
| 2407 | { |
| 2408 | // Fill the stream provider functions |
| 2409 | pStream->StreamRead = pStream->BaseRead; |
| 2410 | pStream->StreamWrite = pStream->BaseWrite; |
| 2411 | pStream->StreamResize = pStream->BaseResize; |
| 2412 | pStream->StreamGetSize = pStream->BaseGetSize; |
| 2413 | pStream->StreamGetPos = pStream->BaseGetPos; |
| 2414 | pStream->StreamClose = pStream->BaseClose; |
| 2415 | return pStream; |
| 2416 | } |
| 2417 | |
| 2418 | // File create failed, delete the stream |
| 2419 | CASC_FREE(pStream); |
| 2420 | } |
| 2421 | |
| 2422 | // Return the stream |
| 2423 | return pStream; |
| 2424 | } |
| 2425 | |
| 2426 | /** |
| 2427 | * This function opens an existing file for read or read-write access |