MCPcopy Create free account
hub / github.com/Parchive/par2cmdline / Open

Method Open

src/diskfile.cpp:244–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

242// Open the file
243
244bool DiskFile::Open(const std::string &_filename, u64 _filesize)
245{
246 assert(hFile == INVALID_HANDLE_VALUE);
247
248 filename = _filename;
249 filesize = _filesize;
250
251 std::wstring wfilename = utf8::Utf8ToWide(_filename);
252 hFile = ::CreateFileW(wfilename.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL);
253 if (hFile == INVALID_HANDLE_VALUE)
254 {
255 DWORD error = ::GetLastError();
256
257 switch (error)
258 {
259 case ERROR_FILE_NOT_FOUND:
260 case ERROR_PATH_NOT_FOUND:
261 break;
262 default:
263 #pragma omp critical
264 *serr << "Could not open \"" << _filename << "\": " << ErrorMessage(error) << std::endl;
265 }
266
267 return false;
268 }
269
270 offset = 0;
271 exists = true;
272
273 return true;
274}
275
276// Read some data from disk
277

Callers 15

test2Function · 0.45
test3Function · 0.45
test6Function · 0.45
LoadPacketsFromFileMethod · 0.45
VerifySourceFilesMethod · 0.45
VerifyExtraFilesMethod · 0.45
ProcessDataMethod · 0.45
VerifyTargetFilesMethod · 0.45
RemoveParFilesMethod · 0.45
OpenSourceFilesMethod · 0.45
ProcessDataMethod · 0.45
LoadRecoveryFileMethod · 0.45

Calls 1

Utf8ToWideFunction · 0.85

Tested by 3

test2Function · 0.36
test3Function · 0.36
test6Function · 0.36