MCPcopy Create free account
hub / github.com/alibaba/MNN / MNNSetFileSize

Function MNNSetFileSize

source/core/MNNFileUtils.cpp:189–212  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189ErrorCode MNNSetFileSize(file_t file, size_t aimed_size)
190{
191 if (file == INVALID_FILE) {
192 return FILE_NOT_EXIST;
193 }
194#if defined(WIN32) || defined(_WIN32) || defined(_WIN64) || defined(_MSC_VER)
195 LARGE_INTEGER size;
196 size.QuadPart = aimed_size;
197 bool success = SetFilePointerEx(file, size, NULL, FILE_BEGIN);
198 if (!success) {
199 return FILE_RESIZE_FAILED;
200 }
201 success = SetEndOfFile(file);
202 if (!success) {
203 return FILE_RESIZE_FAILED;
204 }
205 return NO_ERROR;
206#else
207 if (-1 == ftruncate(file, aimed_size)) {
208 return FILE_RESIZE_FAILED;
209 }
210 return NO_ERROR;
211#endif
212}
213
214size_t MNNReadFile(file_t file, void * buf, size_t bytes)
215{

Callers 7

onAllocMethod · 0.85
syncMethod · 0.85
onExecuteMethod · 0.85
saveKVCacheInDiskMethod · 0.85
resetKVCacheFileSizeMethod · 0.85
onAllocMethod · 0.85
runMethod · 0.85

Calls

no outgoing calls

Tested by 1

runMethod · 0.68