| 1063 | // |
| 1064 | |
| 1065 | bool WINAPI CascGetFileSize64(HANDLE hFile, PULONGLONG PtrFileSize) |
| 1066 | { |
| 1067 | TCascFile * hf; |
| 1068 | DWORD dwErrCode; |
| 1069 | |
| 1070 | // Validate the file pointer |
| 1071 | if(PtrFileSize == NULL) |
| 1072 | { |
| 1073 | SetCascError(ERROR_INVALID_PARAMETER); |
| 1074 | return false; |
| 1075 | } |
| 1076 | |
| 1077 | // Validate the file handle |
| 1078 | if((hf = TCascFile::IsValid(hFile)) == NULL) |
| 1079 | { |
| 1080 | SetCascError(ERROR_INVALID_HANDLE); |
| 1081 | return false; |
| 1082 | } |
| 1083 | |
| 1084 | // If the content key is zeros, we treat the file as a file with size of 0 |
| 1085 | if(hf->ContentSize == 0) |
| 1086 | { |
| 1087 | PtrFileSize[0] = 0; |
| 1088 | return true; |
| 1089 | } |
| 1090 | |
| 1091 | // ENCODING on older storages: Content size is not present in the BUILD file |
| 1092 | // For that reason, we need to query the content size from the file frames |
| 1093 | dwErrCode = EnsureFileSpanFramesLoaded(hf); |
| 1094 | if(dwErrCode != ERROR_SUCCESS) |
| 1095 | { |
| 1096 | SetCascError(dwErrCode); |
| 1097 | return false; |
| 1098 | } |
| 1099 | |
| 1100 | // Give the file size to the caller |
| 1101 | PtrFileSize[0] = hf->ContentSize; |
| 1102 | return true; |
| 1103 | } |
| 1104 | |
| 1105 | DWORD WINAPI CascGetFileSize(HANDLE hFile, PDWORD PtrFileSizeHigh) |
| 1106 | { |