本文整理汇总了C++中VDStringA类的典型用法代码示例。如果您正苦于以下问题:C++ VDStringA类的具体用法?C++ VDStringA怎么用?C++ VDStringA使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VDStringA类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: clear
void MRUList::load() {
clear();
VDRegistryAppKey key(mpKeyName);
if (!key.isReady())
return;
VDStringA s;
if (!key.getString("MRUList", s))
return;
int nItems = std::min<int>(mMaxCount, s.length());
mKey.resize(mMaxCount, 0);
for(int i=0; i<nItems; i++) {
char name[2]={s[i], 0};
if (!name[0])
break;
if (!key.getString(name, mFiles[i]))
break;
mKey[i] = (char)('a'+i);
}
}
开发者ID:KGE-INC,项目名称:VirtualDub,代码行数:27,代码来源:MRUList.cpp
示例2: getString
bool VDRegistryKey::getString(const char *pszName, VDStringA& str) const {
DWORD type, s = sizeof(DWORD);
if (!pHandle || RegQueryValueEx((HKEY)pHandle, pszName, 0, &type, NULL, &s) || type != REG_SZ)
return false;
str.resize(s);
if (RegQueryValueEx((HKEY)pHandle, pszName, 0, NULL, (BYTE *)str.data(), &s))
return false;
if (!s)
str.clear();
else
str.resize(strlen(str.c_str())); // Trim off pesky terminating NULLs.
return true;
}
开发者ID:KGE-INC,项目名称:modplus,代码行数:17,代码来源:registry.cpp
示例3: ToString
VDStringA VDJob::ToString() const {
VDStringA s;
static const char *const kStateNames[]={
"Waiting",
"In progress",
"Completed",
"Postponed",
"Aborted",
"Error",
"Aborting",
"Starting",
};
VDASSERTCT(sizeof(kStateNames) / sizeof(kStateNames[0]) == kStateCount);
s.sprintf("%s | %s | %-11s (%s:%d)", mInputFile.c_str(), mOutputFile.c_str(), kStateNames[mState], mRunnerName.c_str(), (uint32)mRunnerId);
return s;
}
开发者ID:KGE-INC,项目名称:VirtualDub,代码行数:19,代码来源:Job.cpp
示例4: JobAddConfigurationInputs
void JobAddConfigurationInputs(JobScriptOutput& output, const wchar_t *szFileInput, const wchar_t *pszInputDriver, List2<InputFilenameNode> *pListAppended) {
do {
const VDStringA filename(strCify(VDTextWToU8(VDStringW(szFileInput)).c_str()));
if (g_pInputOpts) {
int req = g_pInputOpts->write(NULL, 0);
vdfastvector<char> srcbuf(req);
int srcsize = g_pInputOpts->write(srcbuf.data(), req);
if (srcsize) {
vdfastvector<char> encbuf((srcsize + 2) / 3 * 4 + 1);
membase64(encbuf.data(), srcbuf.data(), srcsize);
const VDStringA filename(strCify(VDTextWToU8(VDStringW(szFileInput)).c_str()));
output.addf("VirtualDub.Open(\"%s\",\"%s\",0,\"%s\");", filename.c_str(), pszInputDriver?strCify(VDTextWToU8(VDStringW(pszInputDriver)).c_str()):"", encbuf.data());
break;
}
}
output.addf("VirtualDub.Open(\"%s\",\"%s\",0);", filename.c_str(), pszInputDriver?strCify(VDTextWToU8(VDStringW(pszInputDriver)).c_str()):"");
} while(false);
if (pListAppended) {
InputFilenameNode *ifn = pListAppended->AtHead(), *ifn_next;
if (ifn = ifn->NextFromHead())
while(ifn_next = ifn->NextFromHead()) {
output.addf("VirtualDub.Append(\"%s\");", strCify(VDTextWToU8(VDStringW(ifn->name)).c_str()));
ifn = ifn_next;
}
}
}
开发者ID:fishman,项目名称:virtualdub,代码行数:36,代码来源:Job.cpp
示例5: JobCreateScript
void JobCreateScript(JobScriptOutput& output, const DubOptions *opt, bool bIncludeEditList = true, bool bIncludeTextInfo = true) {
char *mem= NULL;
char buf[4096];
long l;
int audioSourceMode = g_project->GetAudioSourceMode();
switch(audioSourceMode) {
case kVDAudioSourceMode_External:
{
const VDStringA& encodedFileName = VDEncodeScriptString(VDStringW(g_szInputWAVFile));
const VDStringA& encodedDriverName = VDEncodeScriptString(VDTextWToU8(g_project->GetAudioSourceDriverName(), -1));
// check if we have options to write out
const InputFileOptions *opts = g_project->GetAudioSourceOptions();
if (opts) {
int l;
char buf[256];
l = opts->write(buf, (sizeof buf)/7*3);
if (l) {
membase64(buf+l, (char *)buf, l);
output.addf("VirtualDub.audio.SetSource(\"%s\", \"%s\", \"%s\");", encodedFileName.c_str(), encodedDriverName.c_str(), buf+l);
break;
}
}
// no options
output.addf("VirtualDub.audio.SetSource(\"%s\", \"%s\");", encodedFileName.c_str(), encodedDriverName.c_str());
}
break;
default:
if (audioSourceMode >= kVDAudioSourceMode_Source) {
int index = audioSourceMode - kVDAudioSourceMode_Source;
if (!index)
output.addf("VirtualDub.audio.SetSource(1);");
else
output.addf("VirtualDub.audio.SetSource(1,%d);", index);
break;
}
// fall through
case kVDAudioSourceMode_None:
output.addf("VirtualDub.audio.SetSource(0);");
break;
}
output.addf("VirtualDub.audio.SetMode(%d);", opt->audio.mode);
output.addf("VirtualDub.audio.SetInterleave(%d,%d,%d,%d,%d);",
opt->audio.enabled,
opt->audio.preload,
opt->audio.interval,
opt->audio.is_ms,
opt->audio.offset);
output.addf("VirtualDub.audio.SetClipMode(%d,%d);",
opt->audio.fStartAudio,
opt->audio.fEndAudio);
output.addf("VirtualDub.audio.SetConversion(%d,%d,%d,0,%d);",
opt->audio.new_rate,
opt->audio.newPrecision,
opt->audio.newChannels,
opt->audio.fHighQuality);
if (opt->audio.mVolume >= 0.0f)
output.addf("VirtualDub.audio.SetVolume(%d);", VDRoundToInt(256.0f * opt->audio.mVolume));
else
output.addf("VirtualDub.audio.SetVolume();");
if (g_ACompressionFormat) {
if (g_ACompressionFormat->mExtraSize) {
mem = (char *)allocmem(((g_ACompressionFormat->mExtraSize+2)/3)*4 + 1);
if (!mem) throw MyMemoryError();
membase64(mem, (char *)(g_ACompressionFormat+1), g_ACompressionFormat->mExtraSize);
output.addf("VirtualDub.audio.SetCompressionWithHint(%d,%d,%d,%d,%d,%d,%d,\"%s\",\"%s\");"
,g_ACompressionFormat->mTag
,g_ACompressionFormat->mSamplingRate
,g_ACompressionFormat->mChannels
,g_ACompressionFormat->mSampleBits
,g_ACompressionFormat->mDataRate
,g_ACompressionFormat->mBlockSize
,g_ACompressionFormat->mExtraSize
,mem
,VDEncodeScriptString(g_ACompressionFormatHint).c_str()
);
freemem(mem);
} else
output.addf("VirtualDub.audio.SetCompressionWithHint(%d,%d,%d,%d,%d,%d,\"%s\");"
,g_ACompressionFormat->mTag
,g_ACompressionFormat->mSamplingRate
,g_ACompressionFormat->mChannels
//.........这里部分代码省略.........
开发者ID:fishman,项目名称:virtualdub,代码行数:101,代码来源:Job.cpp
示例6:
size_t vdhash<VDStringA>::operator()(const VDStringA& s) const {
return VDHashString32(s.data(), s.length());
}
开发者ID:AeonAxan,项目名称:mpc-hc,代码行数:3,代码来源:vdstl_hash.cpp
示例7: close
bool VDFile::open_internal(const char *pszFilename, const wchar_t *pwszFilename, uint32 flags, bool throwOnError) {
close();
mpFilename = _wcsdup(VDFileSplitPath(pszFilename ? VDTextAToW(pszFilename).c_str() : pwszFilename));
if (!mpFilename) {
if (!throwOnError)
return false;
throw MyMemoryError();
}
// At least one of the read/write flags must be set.
VDASSERT(flags & (kRead | kWrite));
DWORD dwDesiredAccess = 0;
if (flags & kRead) dwDesiredAccess = GENERIC_READ;
if (flags & kWrite) dwDesiredAccess |= GENERIC_WRITE;
// Win32 docs are screwed here -- FILE_SHARE_xxx is the inverse of a deny flag.
DWORD dwShareMode = FILE_SHARE_READ | FILE_SHARE_WRITE;
if (flags & kDenyRead) dwShareMode = FILE_SHARE_WRITE;
if (flags & kDenyWrite) dwShareMode &= ~FILE_SHARE_WRITE;
// One of the creation flags must be set.
VDASSERT(flags & kCreationMask);
DWORD dwCreationDisposition;
uint32 creationType = flags & kCreationMask;
switch(creationType) {
case kOpenExisting: dwCreationDisposition = OPEN_EXISTING; break;
case kOpenAlways: dwCreationDisposition = OPEN_ALWAYS; break;
case kCreateAlways: dwCreationDisposition = CREATE_ALWAYS; break;
case kCreateNew: dwCreationDisposition = CREATE_NEW; break;
case kTruncateExisting: dwCreationDisposition = TRUNCATE_EXISTING; break;
default:
VDNEVERHERE;
return false;
}
VDASSERT((flags & (kSequential | kRandomAccess)) != (kSequential | kRandomAccess));
DWORD dwAttributes = FILE_ATTRIBUTE_NORMAL;
if (flags & kSequential) dwAttributes |= FILE_FLAG_SEQUENTIAL_SCAN;
if (flags & kRandomAccess) dwAttributes |= FILE_FLAG_RANDOM_ACCESS;
if (flags & kWriteThrough) dwAttributes |= FILE_FLAG_WRITE_THROUGH;
if (flags & kUnbuffered) dwAttributes |= FILE_FLAG_NO_BUFFERING;
VDStringA tempFilenameA;
VDStringW tempFilenameW;
if (IsWindowsNT()) {
if (pszFilename) {
tempFilenameW = VDTextAToW(pszFilename);
pwszFilename = tempFilenameW.c_str();
pszFilename = NULL;
}
} else {
if (pwszFilename) {
tempFilenameA = VDTextWToA(pwszFilename);
pszFilename = tempFilenameA.c_str();
pwszFilename = NULL;
}
}
if (pszFilename)
mhFile = CreateFileA(pszFilename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwAttributes, NULL);
else {
if (!IsHardDrivePath(pwszFilename))
flags &= ~FILE_FLAG_NO_BUFFERING;
mhFile = CreateFileW(pwszFilename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwAttributes, NULL);
}
DWORD err = GetLastError();
// If we failed and FILE_FLAG_NO_BUFFERING was set, strip it and try again.
// VPC and Novell shares sometimes do this....
if (mhFile == INVALID_HANDLE_VALUE && err != ERROR_FILE_NOT_FOUND && err != ERROR_PATH_NOT_FOUND) {
if (dwAttributes & FILE_FLAG_NO_BUFFERING) {
dwAttributes &= ~FILE_FLAG_NO_BUFFERING;
dwAttributes |= FILE_FLAG_WRITE_THROUGH;
if (pszFilename)
mhFile = CreateFileA(pszFilename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwAttributes, NULL);
else
mhFile = CreateFileW(pwszFilename, dwDesiredAccess, dwShareMode, NULL, dwCreationDisposition, dwAttributes, NULL);
err = GetLastError();
}
}
// INVALID_HANDLE_VALUE isn't NULL. *sigh*
if (mhFile == INVALID_HANDLE_VALUE) {
mhFile = NULL;
//.........这里部分代码省略.........
开发者ID:334151798,项目名称:dwindow,代码行数:101,代码来源:file.cpp
示例8:
bool VDRegistryProviderMemory::Key::KeyPred::operator()(const VDStringA& s, const char *t) const {
return s.comparei(t) == 0;
}
开发者ID:1ldk,项目名称:mpc-hc,代码行数:3,代码来源:registrymemory.cpp
示例9:
void vdmove<VDStringA>(VDStringA& dst, VDStringA& src) {
dst.move_from(src);
}
开发者ID:KGE-INC,项目名称:VirtualDub,代码行数:3,代码来源:VDString.cpp
示例10: s
bool VDDialogEditAccelerators::OnCommand(uint32 id, uint32 extcode) {
if (id == IDC_FILTER) {
if (extcode == EN_CHANGE) {
VDStringA s("*");
s += VDTextWToA(GetControlValueString(id)).c_str();
s += '*';
RefilterCommands(s.c_str());
return true;
}
} else if (id == IDC_ADD) {
VDUIAccelerator accel;
int selIdx = LBGetSelectedIndex(IDC_AVAILCOMMANDS);
if ((size_t)selIdx < mFilteredCommands.size()) {
const VDAccelToCommandEntry *ace = mFilteredCommands[selIdx];
if (mpHotKeyControl) {
mpHotKeyControl->GetAccelerator(accel);
// Look for a conflicting command.
for(BoundCommands::iterator it(mBoundCommands.begin()), itEnd(mBoundCommands.end()); it != itEnd; ++it) {
BoundCommand *obc = *it;
if (obc->mAccel == accel) {
VDStringW keyName;
VDUIGetAcceleratorString(accel, keyName);
VDStringA msg;
msg.sprintf("The key %ls is already bound to %hs. Rebind it to %hs?", keyName.c_str(), obc->mpCommand, ace->mpName);
if (IDOK != MessageBox(mhdlg, msg.c_str(), g_szWarning, MB_OKCANCEL | MB_ICONEXCLAMATION))
return true;
mBoundCommands.erase(it);
obc->Release();
}
}
vdrefptr<BoundCommand> bc(new_nothrow BoundCommand);
if (bc) {
bc->mpCommand = ace->mpName;
bc->mCommandId = ace->mId;
bc->mAccel = accel;
mBoundCommands.push_back(bc.release());
RefreshBoundList();
}
}
}
return true;
} else if (id == IDC_REMOVE) {
int selIdx = mListViewBoundCommands.GetSelectedIndex();
if ((unsigned)selIdx < mBoundCommands.size()) {
BoundCommand *bc = mBoundCommands[selIdx];
mBoundCommands.erase(mBoundCommands.begin() + selIdx);
bc->Release();
RefreshBoundList();
}
return true;
} else if (id == IDC_RESET) {
if (IDOK == MessageBox(mhdlg, "Really reset?", g_szWarning, MB_OKCANCEL | MB_ICONEXCLAMATION))
LoadTable(mBoundCommandsDefault);
return true;
}
return false;
}
开发者ID:KGE-INC,项目名称:VirtualDub,代码行数:77,代码来源:AccelEditDialog.cpp
示例11: VDDumpChangeLog
void VDDumpChangeLog() {
HRSRC hResource = FindResource(NULL, MAKEINTRESOURCE(IDR_CHANGES), "STUFF");
if (!hResource)
return;
HGLOBAL hGlobal = LoadResource(NULL, hResource);
if (!hGlobal)
return;
LPVOID lpData = LockResource(hGlobal);
if (!lpData)
return;
const char *s = (const char *)lpData;
while(*s!='\r') ++s;
s+=2;
tTextStream lineBuffer;
VDStringA breakLineBuffer;
bool foundNonIndentedLine = false;
while(*s) {
// parse line
if (*s != ' ') {
if (foundNonIndentedLine)
break;
foundNonIndentedLine = true;
}
const char *end = s;
while(*end && *end != '\r' && *end != '\n')
++end;
lineBuffer.clear();
append_cooked(lineBuffer, s, end, false);
// skip line termination
s = end;
if (*s == '\r' || *s == '\n') {
++s;
if ((s[0] ^ s[-1]) == ('\r' ^ '\n'))
++s;
}
lineBuffer.push_back(0);
// break into lines
const char *t = lineBuffer.data();
int maxLine = 78;
breakLineBuffer.clear();
do {
const char *lineStart = t;
const char *break1 = NULL;
const char *break2 = NULL;
do {
while(*t && *t != ' ')
++t;
const char *u = t;
while(*t && *t == ' ')
++t;
if (u - lineStart > maxLine) {
if (!break1) {
break1 = u + maxLine;
break2 = break1;
}
break;
}
break1 = u;
break2 = t;
} while(*t);
breakLineBuffer.append(lineStart, break1);
VDLog(kVDLogInfo, VDTextAToW(breakLineBuffer.data(), breakLineBuffer.size()));
t = break2;
breakLineBuffer.clear();
breakLineBuffer.resize(5, ' ');
maxLine = 73;
} while(*t);
}
}
开发者ID:fishman,项目名称:virtualdub,代码行数:95,代码来源:auxdlg.cpp
示例12: VDTextWToA
void VDFileAsync9x::Open(const wchar_t *pszFilename, uint32 count, uint32 bufferSize) {
try {
mFilename = VDTextWToA(pszFilename);
const DWORD slowFlags = mbWriteThrough ? FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH : FILE_ATTRIBUTE_NORMAL;
mhFileSlow = CreateFileA(mFilename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, slowFlags, NULL);
if (mhFileSlow == INVALID_HANDLE_VALUE)
throw MyWin32Error("Unable to open file \"%s\" for write: %%s", GetLastError(), mFilename.c_str());
if (mbUseFastMode)
mhFileFast = CreateFileA(mFilename.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING, NULL);
mSectorSize = 4096; // guess for now... proper way would be GetVolumeMountPoint() followed by GetDiskFreeSpace().
mBlockSize = bufferSize;
mBlockCount = count;
mBuffer.Init(count * bufferSize);
mState = kStateNormal;
} catch(const MyError&) {
Close();
throw;
}
ThreadStart();
}
开发者ID:Cyberbeing,项目名称:xy-VSFilter,代码行数:27,代码来源:fileasync.cpp
示例13: Open
void VDFileAsyncNT::Open(VDFileHandle h, uint32 count, uint32 bufferSize) {
try {
mFilename = "<anonymous pipe>";
HANDLE hProcess = GetCurrentProcess();
if (!DuplicateHandle(hProcess, h, hProcess, &mhFileSlow, 0, FALSE, DUPLICATE_SAME_ACCESS))
throw MyWin32Error("Unable to open file \"%s\" for write: %%s", GetLastError(), mFilename.c_str());
mSectorSize = 4096; // guess for now... proper way would be GetVolumeMountPoint() followed by GetDiskFreeSpace().
mBlockSize = bufferSize;
mBlockCount = count;
mBufferSize = mBlockSize * mBlockCount;
mWriteOffset = 0;
mBufferLevel = 0;
mState = kStateNormal;
if (mhFileFast != INVALID_HANDLE_VALUE) {
mpBlocks = new VDFileAsyncNTBuffer[count];
mBuffer.resize(count * bufferSize);
ThreadStart();
}
} catch(const MyError&) {
Close();
throw;
}
}
开发者ID:Cyberbeing,项目名称:xy-VSFilter,代码行数:29,代码来源:fileasync.cpp
示例14: Write
void VDFileAsyncNT::Write(sint64 pos, const void *p, uint32 bytes) {
Seek(pos);
DWORD dwActual;
if (!WriteFile(mhFileSlow, p, bytes, &dwActual, NULL) || (mClientSlowPointer += dwActual),(dwActual != bytes))
throw MyWin32Error("Write error occurred on file \"%s\": %%s", GetLastError(), mFilename.c_str());
}
开发者ID:Cyberbeing,项目名称:xy-VSFilter,代码行数:7,代码来源:fileasync.cpp
示例15: ExecuteLine
void VDScriptInterpreter::ExecuteLine(const char *s) {
int t;
mErrorExtraToken.clear();
TokenBegin(s);
while(t = Token()) {
if (isExprFirstToken(t)) {
TokenUnput(t);
VDASSERT(mStack.empty());
ParseExpression();
VDASSERT(!mStack.empty());
VDScriptValue& val = mStack.back();
mStack.pop_back();
VDASSERT(mStack.empty());
if (Token() != ';')
SCRIPT_ERROR(SEMICOLON_EXPECTED);
} else if (t == TOK_DECLARE) {
do {
t = Token();
if (t != TOK_IDENT)
SCRIPT_ERROR(IDENTIFIER_EXPECTED);
VariableTableEntry *vte = vartbl.Declare(szIdent);
t = Token();
if (t == '=') {
ParseExpression();
VDASSERT(!mStack.empty());
vte->v = mStack.back();
mStack.pop_back();
t = Token();
}
} while(t == ',');
if (t != ';')
SCRIPT_ERROR(SEMICOLON_EXPECTED);
} else
SCRIPT_ERROR(PARSE_ERROR);
}
VDASSERT(mStack.empty());
GC();
}
开发者ID:KGE-INC,项目名称:modplus,代码行数:57,代码来源:ScriptInterpreter.cpp
示例16: GetSize
sint64 VDFileAsyncNT::GetSize() {
DWORD dwSizeHigh;
DWORD dwSizeLow = GetFileSize(mhFileSlow, &dwSizeHigh);
if (dwSizeLow == (DWORD)-1 && GetLastError() != NO_ERROR)
throw MyWin32Error("I/O error on file \"%s\": %%s", GetLastError(), mFilename.c_str());
return dwSizeLow + ((sint64)dwSizeHigh << 32);
}
开发者ID:Cyberbeing,项目名称:xy-VSFilter,代码行数:9,代码来源:fileasync.cpp
示例17: Run
void VDVideoFilterShowInfo::Run() {
const VDXFBitmap& dst = *fa->mpOutputFrames[0];
const VDXPixmap& pxdst = *dst.mpPixmap;
const float size = 8.0f * 8.0f * 20.0f;
VDPixmap pxdst2;
pxdst2.data = pxdst.data;
pxdst2.data2 = pxdst.data2;
pxdst2.data3 = pxdst.data3;
pxdst2.pitch = pxdst.pitch;
pxdst2.pitch2 = pxdst.pitch2;
pxdst2.pitch3 = pxdst.pitch3;
pxdst2.format = pxdst.format;
pxdst2.w = pxdst.w;
pxdst2.h = pxdst.h;
pxdst2.palette = pxdst.palette;
float y = 20.0f;
for(int lines=0; lines<3; ++lines) {
switch(lines) {
case 0:
mTextLine.sprintf("Source frame: %d (%.3fs)", (int)fa->pfsi->lCurrentSourceFrame, (double)fa->pfsi->lSourceFrameMS / 1000.0);
break;
case 1:
mTextLine.sprintf("Output frame: %d", (int)fa->pfsi->mOutputFrame);
break;
case 2:
mTextLine.sprintf("Sequence frame: %d (%.3fs)", (int)fa->pfsi->lCurrentFrame, (double)fa->pfsi->lDestFrameMS / 1000.0);
break;
}
mRasterizer.Clear();
VDPixmapConvertTextToPath(mRasterizer, NULL, size, 8.0f * 8.0f * 10.0f, 8.0f * 8.0f * y, mTextLine.c_str());
mRasterizer.ScanConvert(mTextRegion);
VDPixmapConvolveRegion(mShadowRegion, mTextRegion, mShadowBrush);
VDPixmapFillRegionAntialiased8x(pxdst2, mShadowRegion, 0, 0, 0xFF000000);
VDPixmapFillRegionAntialiased8x(pxdst2, mTextRegion, 0, 0, 0xFFFFFF00);
y += 20.0f;
}
}
开发者ID:fishman,项目名称:virtualdub,代码行数:43,代码来源:f_showinfo.cpp
示例18: ThreadRun
void VDFileAsyncNT::ThreadRun() {
int requestHead = 0;
int requestTail = 0;
int requestCount = mBlockCount;
uint32 pendingLevel = 0;
uint32 readOffset = 0;
bool bPreemptiveExtend = mbPreemptiveExtend;
sint64 currentSize;
try {
if (!VDGetFileSizeW32(mhFileFast, currentSize))
throw MyWin32Error("I/O error on file \"%s\": %%s", GetLastError(), mFilename.c_str());
for(;;) {
int state = mState;
if (state == kStateAbort) {
typedef BOOL (WINAPI *tpCancelIo)(HANDLE);
static const tpCancelIo pCancelIo = (tpCancelIo)GetProcAddress(GetModuleHandle(L"kernel32"), "CancelIo");
pCancelIo(mhFileFast);
// Wait for any pending blocks to complete.
for(int i=0; i<requestCount; ++i) {
VDFileAsyncNTBuffer& buf = mpBlocks[i];
if (buf.mbActive) {
WaitForSingleObject(buf.hEvent, INFINITE);
buf.mbActive = false;
}
}
break;
}
uint32 actual = mBufferLevel - pendingLevel;
VDASSERT((int)actual >= 0);
if (readOffset + actual > mBufferSize)
actual = mBufferSize - readOffset;
if (actual < mBlockSize) {
if (state == kStateNormal || actual < mSectorSize) {
// check for blocks that have completed
bool blocksCompleted = false;
for(;;) {
VDFileAsyncNTBuffer& buf = mpBlocks[requestTail];
if (!buf.mbActive) {
if (state == kStateFlush)
goto all_done;
if (!blocksCompleted) {
// wait for further writes
mWriteOccurred.wait();
}
break;
}
if (buf.mbPending) {
HANDLE h[2] = {buf.hEvent, mWriteOccurred.getHandle()};
DWORD waitResult = WaitForMultipleObjects(2, h, FALSE, INFINITE);
if (waitResult == WAIT_OBJECT_0+1) // write pending
break;
DWORD dwActual;
if (!GetOverlappedResult(mhFileFast, &buf, &dwActual, TRUE))
throw MyWin32Error("Write error occurred on file \"%s\": %%s", GetLastError(), mFilename.c_str());
}
buf.mbActive = false;
blocksCompleted = true;
if (++requestTail >= requestCount)
requestTail = 0;
mBufferLevel -= buf.mLength;
pendingLevel -= buf.mLength;
VDASSERT((int)mBufferLevel >= 0);
VDASSERT((int)pendingLevel >= 0);
mReadOccurred.signal();
}
continue;
}
VDASSERT(state == kStateFlush);
actual &= ~(mSectorSize-1);
VDASSERT(actual > 0);
} else {
actual = mBlockSize;
if (bPreemptiveExtend) {
sint64 checkpt = mFastPointer + mBlockSize + mBufferSize;
if (checkpt > currentSize) {
currentSize += mBufferSize;
//.........这里部分代码省略.........
开发者ID:Cyberbeing,项目名称:xy-VSFilter,代码行数:101,代码来源:fileasync.cpp
示例19: Seek
void VDFileAsyncNT::Seek(sint64 pos) {
if (!SeekNT(pos))
throw MyWin32Error("I/O error on file \"%s\": %%s", GetLastError(), mFilename.c_str());
}
开发者ID:Cyberbeing,项目名称:xy-VSFilter,代码行数:4,代码来源:fileasync.cpp
示例20: Truncate
void VDFileAsyncNT::Truncate(sint64 pos) {
Seek(pos);
if (!SetEndOfFile(mhFileSlow))
throw MyWin32Error("I/O error on file \"%s\": %%s", GetLastError(), mFilename.c_str());
}
开发者ID:Cyberbeing,项目名称:xy-VSFilter,代码行数:5,代码来源:fileasync.cpp
注:本文中的VDStringA类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论