本文整理汇总了C++中util::fs::FileHandle::open方法的典型用法代码示例。如果您正苦于以下问题:C++ FileHandle::open方法的具体用法?C++ FileHandle::open怎么用?C++ FileHandle::open使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类util::fs::FileHandle
的用法示例。
在下文中一共展示了FileHandle::open方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeThreads
bool SMTController::makeThreads()
{
for (uint32 x=0; x<m_uiNumber; x++)
{
gcString file("{0}", m_szFile);
UTIL::FS::FileHandle* fh = new UTIL::FS::FileHandle();
if (x != 0)
file += gcString(".part_{0}", x);
try
{
fh->open(file.c_str(), UTIL::FS::FILE_WRITE);
//due to the first thread being the proper MCF we have to allow for the header.
if (x == 0)
fh->seek(MCFCore::MCFHeader::getSizeS());
}
catch (gcException &except)
{
safe_delete(fh);
onErrorEvent(except);
return false;
}
SMTWorkerInfo* temp = new SMTWorkerInfo(this, x, fh, file.c_str());
m_vWorkerList.push_back(temp);
temp->workThread->start();
m_iRunningWorkers++;
}
return true;
}
示例2: OpenFileForWrite
int32 FileSystemJSBinding::OpenFileForWrite(gcString file)
{
UTIL::FS::Path path = UTIL::FS::PathWithFile(file);
UTIL::FS::recMakeFolder(path);
UTIL::FS::FileHandle* handle = new UTIL::FS::FileHandle();
try
{
handle->open(path, UTIL::FS::FILE_WRITE);
m_vFileHandles.push_back(handle);
return m_vFileHandles.size() - 1;
}
catch (gcException &e)
{
safe_delete(handle);
Warning("Failed to to open file in scriptcore: {0}\n", e);
}
return 0;
}
示例3: postProcessing
void SMTController::postProcessing()
{
if (m_uiNumber == 1)
return;
UTIL::FS::FileHandle fhSource;
UTIL::FS::FileHandle fhSink;
UTIL::FS::Path path(m_szFile, "", true);
uint64 sinkSize = UTIL::FS::getFileSize(path);
try
{
fhSink.open(path, UTIL::FS::FILE_APPEND);
}
catch (gcException &)
{
return;
}
char buff[BLOCKSIZE];
for (size_t x=1; x<m_vWorkerList.size(); x++)
{
SMTWorkerInfo *worker = m_vWorkerList[x];
uint64 fileSize = UTIL::FS::getFileSize(UTIL::FS::PathWithFile(worker->file));
uint64 done = 0;
uint32 readSize = BLOCKSIZE;
try
{
fhSource.open(worker->file.c_str(), UTIL::FS::FILE_READ);
while (fileSize > done)
{
if ((fileSize-done) < (uint64)readSize)
readSize = (uint32)(fileSize-done);
fhSource.read(buff, readSize);
fhSink.write(buff, readSize);
done += readSize;
}
fhSource.close();
}
catch (gcException &)
{
}
for (size_t y=0; y<worker->vFileList.size(); y++)
{
uint32 index = worker->vFileList[y];
MCFCore::MCFFile *temp = m_rvFileList[index];
if (!temp)
continue;
temp->setOffSet( temp->getOffSet() + sinkSize );
}
sinkSize += fileSize;
UTIL::FS::delFile(UTIL::FS::PathWithFile(worker->file));
}
if (m_bCreateDiff == false)
return;
}
示例4: getWriteHandle
void MCF::getWriteHandle(UTIL::FS::FileHandle& handle)
{
assert(m_uiFileOffset == 0);
handle.open(m_szFile.c_str(), UTIL::FS::FILE_WRITE, m_uiFileOffset);
}
示例5: getReadHandle
void MCF::getReadHandle(UTIL::FS::FileHandle& handle)
{
handle.open(m_szFile.c_str(), UTIL::FS::FILE_READ, m_uiFileOffset);
}
示例6: UploadDump
bool UploadDump(const char* file, const char* user, int build, int branch, DelegateI<Prog_s&>* progress, const char* szTracer)
{
if (build == 0)
build = 9999;
if (branch == 0)
branch = BUILDID_PUBLIC;
g_Logger.write("---------------------------------------\r\n");
time_t ltime; /* calendar time */
ltime=time(nullptr); /* get current cal time */
#if defined(WIN32) && !defined(__MINGW32__)
char buff[255] = {0};
struct tm t;
localtime_s(&t, <ime);
asctime_s(buff, 255, &t);
#else
struct tm *t = localtime(<ime);
char* buff = asctime(t);
#endif
g_Logger.write("%s\r\n", buff);
g_Logger.write("---------------------------------------\r\n");
g_Logger.write("Uploaded crash dump: [%s]\r\n", file);
gcString dump(file);
gcString tracer(szTracer);
gcString log(dump + ".log");
if (PrepDumpForUpload(dump) == false)
{
g_Logger.write("Failed to prepare crash dump.\r\n");
return false;
}
else
{
g_Logger.write("Prepared crash dump to: [%s]\r\n", dump.c_str());
}
if (!tracer.empty())
{
try
{
auto valid = false;
UTIL::FS::FileHandle fh;
std::function<void(const char*, uint32)> write = [&fh, &valid, log](const char* szData, uint32 nSize)
{
if (!valid)
fh.open(log.c_str(), UTIL::FS::FILE_WRITE);
valid = true;
fh.write(szData, nSize);
};
DumpTracerToFile(tracer, write);
if (!valid)
log = "";
}
catch (...)
{
log = "";
}
if (!log.empty())
PrepDumpForUpload(log);
#ifdef WIN32
//Let desura exit now.
gcString tracerEventName("Global\\{0}Event", tracer);
auto hHandle = OpenEvent(EVENT_MODIFY_STATE, FALSE, tracerEventName.c_str());
if (hHandle)
{
SetEvent(hHandle);
CloseHandle(hHandle);
}
#endif
}
std::string os = UTIL::OS::getOSString();
HttpHandle hh(DUMP_UPLOAD_URL);
if (progress)
hh->getProgressEvent() += progress;
hh->setUserAgent(DUMP_UPLOAD_AGENT);
hh->cleanUp();
hh->addPostText("os", os.c_str());
hh->addPostText("build", build);
//.........这里部分代码省略.........