Exemple #1
0
void VDMoveFile(const wchar_t *srcPath, const wchar_t *dstPath) {
    bool success;
    if (VDIsWindowsNT()) {
        success = MoveFileW(srcPath, dstPath) != 0;
    } else {
        success = MoveFileA(VDTextWToA(srcPath).c_str(), VDTextWToA(dstPath).c_str()) != 0;
    }

    if (!success)
        throw MyWin32Error("Cannot rename \"%ls\" to \"%ls\": %%s", GetLastError(), srcPath, dstPath);
}
Exemple #2
0
sint64 VDGetDiskFreeSpace(const wchar_t *path) {
    typedef BOOL (WINAPI *tpGetDiskFreeSpaceExA)(LPCSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes);
    typedef BOOL (WINAPI *tpGetDiskFreeSpaceExW)(LPCWSTR lpDirectoryName, PULARGE_INTEGER lpFreeBytesAvailable, PULARGE_INTEGER lpTotalNumberOfBytes, PULARGE_INTEGER lpTotalNumberOfFreeBytes);

    static bool sbChecked = false;
    static tpGetDiskFreeSpaceExA spGetDiskFreeSpaceExA;
    static tpGetDiskFreeSpaceExW spGetDiskFreeSpaceExW;

    if (!sbChecked) {
        HMODULE hmodKernel = GetModuleHandle("kernel32.dll");
        spGetDiskFreeSpaceExA = (tpGetDiskFreeSpaceExA)GetProcAddress(hmodKernel, "GetDiskFreeSpaceExA");
        spGetDiskFreeSpaceExW = (tpGetDiskFreeSpaceExW)GetProcAddress(hmodKernel, "GetDiskFreeSpaceExW");

        sbChecked = true;
    }

    if (spGetDiskFreeSpaceExA) {
        BOOL success;
        uint64 freeClient, totalBytes, totalFreeBytes;
        VDStringW directoryName(path);

        if (!directoryName.empty()) {
            wchar_t c = directoryName[directoryName.length()-1];

            if (c != L'/' && c != L'\\')
                directoryName += L'\\';
        }

        if ((LONG)GetVersion() < 0)
            success = spGetDiskFreeSpaceExA(VDTextWToA(directoryName).c_str(), (PULARGE_INTEGER)&freeClient, (PULARGE_INTEGER)&totalBytes, (PULARGE_INTEGER)&totalFreeBytes);
        else
            success = spGetDiskFreeSpaceExW(directoryName.c_str(), (PULARGE_INTEGER)&freeClient, (PULARGE_INTEGER)&totalBytes, (PULARGE_INTEGER)&totalFreeBytes);

        return success ? (sint64)freeClient : -1;
    } else {
        DWORD sectorsPerCluster, bytesPerSector, freeClusters, totalClusters;
        BOOL success;

        VDStringW rootPath(VDFileGetRootPath(path));

        if ((LONG)GetVersion() < 0)
            success = GetDiskFreeSpaceA(rootPath.empty() ? NULL : VDTextWToA(rootPath).c_str(), &sectorsPerCluster, &bytesPerSector, &freeClusters, &totalClusters);
        else
            success = GetDiskFreeSpaceW(rootPath.empty() ? NULL : rootPath.c_str(), &sectorsPerCluster, &bytesPerSector, &freeClusters, &totalClusters);

        return success ? (sint64)((uint64)sectorsPerCluster * bytesPerSector * freeClusters) : -1;
    }
}
Exemple #3
0
void VDUIListViewW32::SetItemText(int item, int subitem, const wchar_t *text) {
	DWORD dwMask = LVIF_TEXT;

	if (VDIsWindowsNT()) {
		LVITEMW lviw={0};

		lviw.mask		= dwMask;
		lviw.iItem		= item;
		lviw.iSubItem	= subitem;
		lviw.pszText	= (LPWSTR)text;

		SendMessageW(mhwnd, LVM_SETITEMTEXTW, (WPARAM)item, (LPARAM)&lviw);
	} else {
		LVITEMA lvia={0};

		VDStringA textA(VDTextWToA(text));

		lvia.mask		= dwMask;
		lvia.iItem		= item;
		lvia.iSubItem	= subitem;
		lvia.pszText	= (LPSTR)textA.c_str();

		SendMessageA(mhwnd, LVM_SETITEMTEXTA, (WPARAM)item, (LPARAM)&lvia);
	}
}
Exemple #4
0
INT_PTR CALLBACK FrameServerSetupDlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) {
	switch(msg) {
	case WM_INITDIALOG:
		{
			char buf[32];

			ivdsl->GetComputerName(buf);
			strcat(buf,"/");

			SetDlgItemText(hDlg, IDC_COMPUTER_NAME, buf);
		}
		SetDlgItemText(hDlg, IDC_FSNAME, VDTextWToA(VDFileSplitPath(g_szInputAVIFile)).c_str());
		SetWindowLongPtr(hDlg, DWLP_USER, lParam);
		return TRUE;
	case WM_COMMAND:
		switch(LOWORD(wParam)) {
		case IDOK:
			SendDlgItemMessage(hDlg, IDC_FSNAME, WM_GETTEXT, 128, GetWindowLongPtr(hDlg, DWLP_USER));
			EndDialog(hDlg, TRUE);
			break;
		case IDCANCEL:
			EndDialog(hDlg, FALSE);
			break;
		}
		break;
	}

	return FALSE;
}
Exemple #5
0
void VDUIListViewW32::AddColumn(const wchar_t *name, int width, int affinity) {
	VDASSERT(affinity >= 0);
	VDASSERT(width >= 0);

	if (VDIsWindowsNT()) {
		LVCOLUMNW lvcw={0};

		lvcw.mask		= LVCF_TEXT | LVCF_WIDTH;
		lvcw.pszText	= (LPWSTR)name;
		lvcw.cx			= width;

		SendMessageW(mhwnd, LVM_INSERTCOLUMNW, mColumns.size(), (LPARAM)&lvcw);
	} else {
		LVCOLUMNA lvca={0};
		VDStringA nameA(VDTextWToA(name));

		lvca.mask		= LVCF_TEXT | LVCF_WIDTH;
		lvca.pszText	= (LPSTR)nameA.c_str();
		lvca.cx			= width;

		SendMessageA(mhwnd, LVM_INSERTCOLUMNA, mColumns.size(), (LPARAM)&lvca);
	}

	mColumns.push_back(Column());
	Column& col = mColumns.back();

	col.mWidth		= width;
	col.mAffinity	= affinity;

	mTotalWidth		+= width;
	mTotalAffinity	+= affinity;

	OnResize();
}
Exemple #6
0
void VDFileAsyncNT::Open(const wchar_t *pszFilename, uint32 count, uint32 bufferSize) {
	try {
		mFilename = VDTextWToA(pszFilename);

		mhFileSlow = CreateFileW(pszFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
		if (mhFileSlow == INVALID_HANDLE_VALUE)
			throw MyWin32Error("Unable to open file \"%s\" for write: %%s", GetLastError(), mFilename.c_str());

		mhFileFast = CreateFileW(pszFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING | FILE_FLAG_OVERLAPPED, NULL);
		if (mhFileFast == INVALID_HANDLE_VALUE)
			mhFileFast = CreateFileW(pszFilename, GENERIC_WRITE, FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_WRITE_THROUGH | FILE_FLAG_OVERLAPPED, NULL);

		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;
	}
}
Exemple #7
0
void VDSymbolSourceLinkMap::Init(const wchar_t *filename) {
	if (const wchar_t *b = wcschr(filename, L'!')) {
		std::wstring fn(filename, b - filename);

		VDFileStream fileStream(fn.c_str());
		VDZipArchive zipArchive;

		zipArchive.Init(&fileStream);

		sint32 n = zipArchive.GetFileCount();
		VDStringA name(VDTextWToA(b+1));

		for(int i=0; i<n; ++i) {
			const VDZipArchive::FileInfo& fileInfo = zipArchive.GetFileInfo(i);

			if (fileInfo.mFileName == name) {
				IVDStream *pStream = zipArchive.OpenRawStream(i);

				VDZipStream zipStream(pStream, fileInfo.mCompressedSize, !fileInfo.mbPacked);
				Init(&zipStream);
				return;
			}
		}

		throw "Can't find file in zip archive.";
	}

	VDFileStream fileStream(filename);
	Init(&fileStream);
}
Exemple #8
0
void VDAppendMenuW32(HMENU hmenu, UINT flags, UINT id, const wchar_t *text){
	if (VDIsWindowsNT()) {
		AppendMenuW(hmenu, flags, id, text);
	} else {
		AppendMenuA(hmenu, flags, id, VDTextWToA(text).c_str());
	}
}
Exemple #9
0
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();
}
Exemple #10
0
void VDSetWindowTextW32(HWND hwnd, const wchar_t *s) {
	if (VDIsWindowsNT()) {
		SetWindowTextW(hwnd, s);
	} else {
		SetWindowTextA(hwnd, VDTextWToA(s).c_str());
	}
}
Exemple #11
0
bool IsFilenameOnFATVolume(const wchar_t *pszFilename) {
	VDStringW rootPath(VDFileGetRootPath(pszFilename));

	if (VDIsWindowsNT()) {
		DWORD dwMaxComponentLength;
		DWORD dwFSFlags;
		wchar_t szFilesystem[MAX_PATH];

		if (!GetVolumeInformationW(rootPath.c_str(),
				NULL, 0,		// Volume name buffer
				NULL,			// Serial number buffer
				&dwMaxComponentLength,
				&dwFSFlags,
				szFilesystem,
				MAX_PATH))
			return false;

		return !_wcsnicmp(szFilesystem, L"FAT", 3);
	} else {
		DWORD dwMaxComponentLength;
		DWORD dwFSFlags;
		char szFilesystem[MAX_PATH];

		if (!GetVolumeInformationA(VDTextWToA(rootPath).c_str(),
				NULL, 0,		// Volume name buffer
				NULL,			// Serial number buffer
				&dwMaxComponentLength,
				&dwFSFlags,
				szFilesystem,
				sizeof szFilesystem))
			return false;

		return !_strnicmp(szFilesystem, "FAT", 3);
	}
}
Exemple #12
0
void VDFileSetAttributes(const wchar_t *path, uint32 attrsToChange, uint32 newAttrs) {
    const uint32 nativeAttrMask = VDFileGetNativeAttributesFromAttrsW32(attrsToChange);
    const uint32 nativeAttrVals = VDFileGetNativeAttributesFromAttrsW32(newAttrs);

    if (VDIsWindowsNT()) {
        DWORD nativeAttrs = ::GetFileAttributesW(path);

        if (nativeAttrs != INVALID_FILE_ATTRIBUTES) {
            nativeAttrs ^= (nativeAttrs ^ nativeAttrVals) & nativeAttrMask;

            if (::SetFileAttributesW(path, nativeAttrs))
                return;
        }
    } else {
        VDStringA pathA(VDTextWToA(path));

        DWORD nativeAttrs = ::GetFileAttributesA(pathA.c_str());

        if (nativeAttrs != INVALID_FILE_ATTRIBUTES) {
            nativeAttrs ^= (nativeAttrs ^ nativeAttrVals) & nativeAttrMask;

            if (::SetFileAttributesA(pathA.c_str(), nativeAttrs))
                return;
        }
    }

    throw MyWin32Error("Cannot change attributes on \"%ls\": %%s.", GetLastError(), path);
}
Exemple #13
0
bool VDAppendPopupMenuW32(HMENU hmenu, UINT flags, HMENU hmenuPopup, const wchar_t *text){
	flags |= MF_POPUP;

	if (VDIsWindowsNT())
		return 0 != AppendMenuW(hmenu, flags, (UINT_PTR)hmenuPopup, text);
	else
		return 0 != AppendMenuA(hmenu, flags, (UINT_PTR)hmenuPopup, VDTextWToA(text).c_str());
}
Exemple #14
0
void VDCopyTextToClipboard(const wchar_t *s) {
	if (VDIsWindowsNT())
		VDCopyTextToClipboardW(s);
	else {
		VDStringA sa(VDTextWToA(s));

		VDCopyTextToClipboardA(sa.c_str());
	}
}
Exemple #15
0
uint32 VDFileGetAttributes(const wchar_t *path) {
    uint32 nativeAttrs = 0;
    if (VDIsWindowsNT())
        nativeAttrs = ::GetFileAttributesW(path);
    else
        nativeAttrs = ::GetFileAttributesA(VDTextWToA(path).c_str());

    return VDFileGetAttributesFromNativeW32(nativeAttrs);
}
int VideoSourceImages::_read(VDPosition lStart, uint32 lCount, void *lpBuffer, uint32 cbBuffer, uint32 *plBytesRead, uint32 *plSamplesRead) {
	if (plBytesRead)
		*plBytesRead = 0;

	if (plSamplesRead)
		*plSamplesRead = 0;

	const wchar_t *buf = mpParent->ComputeFilename(mPathBuf, lStart);

	// Check if we already have the file handle cached.  If not, open the file.
	
	if (lStart == mCachedHandleFrame) {
		mCachedFile.seek(0);
	} else{
		mCachedHandleFrame = -1;
		mCachedFile.closeNT();
		mCachedFile.open(buf, nsVDFile::kRead | nsVDFile::kDenyWrite | nsVDFile::kOpenExisting);
		mCachedHandleFrame = lStart;
	}

	// Replace

	uint32 size = (uint32)mCachedFile.size();

	if (size > 0x3fffffff)
		throw MyError("VideoSourceImages: File \"%s\" is too large (>1GB).", VDTextWToA(buf).c_str());

	if (!lpBuffer) {
		if (plBytesRead)
			*plBytesRead = size;

		if (plSamplesRead)
			*plSamplesRead = 1;

		return 0;
	}

	if (size > cbBuffer) {
		if (plBytesRead)
			*plBytesRead = size;

		return IVDStreamSource::kBufferTooSmall;
	}

	mCachedFile.read(lpBuffer, size);
	
	if (plBytesRead)
		*plBytesRead = size;

	if (plSamplesRead)
		*plSamplesRead = 1;

	return 0;
}
Exemple #17
0
bool VDDoesPathExist(const wchar_t *fileName) {
    bool bExists;

    if (!(GetVersion() & 0x80000000)) {
        bExists = ((DWORD)-1 != GetFileAttributesW(fileName));
    } else {
        bExists = ((DWORD)-1 != GetFileAttributesA(VDTextWToA(fileName).c_str()));
    }

    return bExists;
}
Exemple #18
0
void VDShowHelp(HWND hwnd, const wchar_t *filename) {
	try {
		VDStringW helpFile(VDGetHelpPath());

		if (!VDDoesPathExist(helpFile.c_str()))
			throw MyError("Cannot find help file: %ls", helpFile.c_str());

		// If we're on Windows NT, check for the ADS and/or network drive.
		if (VDIsWindowsNT()) {
			VDStringW helpFileADS(helpFile);
			helpFileADS += L":Zone.Identifier";
			if (VDDoesPathExist(helpFileADS.c_str())) {
				int rv = MessageBox(hwnd, "VirtualDub has detected that its help file, VirtualDub.chm, has an Internet Explorer download location marker on it. This may prevent the help file from being displayed properly, resulting in \"Action canceled\" errors being displayed. Would you like to remove it?", "VirtualDub warning", MB_YESNO|MB_ICONEXCLAMATION);

				if (rv == IDYES)
					DeleteFileW(helpFileADS.c_str());
			}
		}

		if (filename) {
			helpFile.append(L"::/");
			helpFile.append(filename);
		}

		VDStringW helpCommand(VDStringW(L"\"hh.exe\" \"") + helpFile + L'"');

		PROCESS_INFORMATION pi;
		BOOL retval;

		// CreateProcess will actually modify the string that it gets, soo....
		if (VDIsWindowsNT()) {
			STARTUPINFOW si = {sizeof(STARTUPINFOW)};
			std::vector<wchar_t> tempbufW(helpCommand.size() + 1, 0);
			helpCommand.copy(&tempbufW[0], tempbufW.size());
			retval = CreateProcessW(NULL, &tempbufW[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		} else {
			STARTUPINFOA si = {sizeof(STARTUPINFOA)};
			VDStringA strA(VDTextWToA(helpCommand));
			std::vector<char> tempbufA(strA.size() + 1, 0);
			strA.copy(&tempbufA[0], tempbufA.size());
			retval = CreateProcessA(NULL, &tempbufA[0], NULL, NULL, FALSE, CREATE_DEFAULT_ERROR_MODE, NULL, NULL, &si, &pi);
		}

		if (retval) {
			CloseHandle(pi.hThread);
			CloseHandle(pi.hProcess);
		} else
			throw MyWin32Error("Cannot launch HTML Help: %%s", GetLastError());
	} catch(const MyError& e) {
		e.post(hwnd, g_szError);
	}
}
Exemple #19
0
int VDUIComboBoxW32::AddItem(const wchar_t *text, uintptr data) {
	int sel;

	if (VDIsWindowsNT())
		sel = (int)SendMessageW(mhwnd, CB_ADDSTRING, 0, (LPARAM)text);
	else
		sel = (int)SendMessageA(mhwnd, CB_ADDSTRING, 0, (LPARAM)VDTextWToA(text).c_str());

	if (sel >= 0)
		SendMessage(mhwnd, CB_SETITEMDATA, (WPARAM)sel, (LPARAM)data);

	return sel;
}
Exemple #20
0
int VDUIListBoxW32::AddItem(const wchar_t *text, uintptr data) {
	int idx;

	if (VDIsWindowsNT())
		idx = (int)SendMessageW(mhwnd, LB_ADDSTRING, 0, (LPARAM)text);
	else
		idx = (int)SendMessageA(mhwnd, LB_ADDSTRING, 0, (LPARAM)VDTextWToA(text).c_str());

	if (idx >= 0)
		SendMessage(mhwnd, LB_SETITEMDATA, (WPARAM)idx, (LPARAM)data);

	return idx;
}
Exemple #21
0
bool VDRegistryKey::setString(const char *pszName, const wchar_t *pszString) const {
	if (pHandle) {
		if (GetVersion() & 0x80000000) {
			VDStringA s(VDTextWToA(pszString));

			if (RegSetValueEx((HKEY)pHandle, pszName, 0, REG_SZ, (const BYTE *)s.data(), s.size()))
				return true;
		} else {
			if (RegSetValueExW((HKEY)pHandle, VDTextAToW(pszName).c_str(), 0, REG_SZ, (const BYTE *)pszString, sizeof(wchar_t) * wcslen(pszString)))
				return true;
		}
	}

	return false;
}
Exemple #22
0
void guiSetTitleW(HWND hWnd, UINT uID, ...) {
	wchar_t buf2[256];
	va_list val;

	VDStringW s(VDLoadStringW32(uID));

	va_start(val, uID);
	vswprintf(buf2, 256, s.c_str(), val);
	va_end(val);

	if (GetVersion() < 0x80000000)
		SetWindowTextW(hWnd, buf2);
	else
		SetWindowText(hWnd, VDTextWToA(buf2).c_str());
}
Exemple #23
0
bool VDDirectoryIterator::Next() {
    if (mbSearchComplete)
        return false;

    union {
        WIN32_FIND_DATAA a;
        WIN32_FIND_DATAW w;
    } wfd;

    uint32 attribs;

    if (GetVersion() & 0x80000000) {
        if (mpHandle)
            mbSearchComplete = !FindNextFileA((HANDLE)mpHandle, &wfd.a);
        else {
            mpHandle = FindFirstFileA(VDTextWToA(mSearchPath).c_str(), &wfd.a);
            mbSearchComplete = (INVALID_HANDLE_VALUE == mpHandle);
        }
        if (mbSearchComplete)
            return false;

        mbDirectory = (wfd.a.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
        mFilename = VDTextAToW(wfd.a.cFileName);
        mFileSize = wfd.a.nFileSizeLow + ((sint64)wfd.w.nFileSizeHigh << 32);
        mLastWriteDate.mTicks = wfd.a.ftLastWriteTime.dwLowDateTime + ((uint64)wfd.a.ftLastWriteTime.dwHighDateTime << 32);

        attribs = wfd.a.dwFileAttributes;
    } else {
        if (mpHandle)
            mbSearchComplete = !FindNextFileW((HANDLE)mpHandle, &wfd.w);
        else {
            mpHandle = FindFirstFileW(mSearchPath.c_str(), &wfd.w);
            mbSearchComplete = (INVALID_HANDLE_VALUE == mpHandle);
        }
        if (mbSearchComplete)
            return false;

        mbDirectory = (wfd.w.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) != 0;
        mFilename = wfd.w.cFileName;
        mFileSize = wfd.w.nFileSizeLow + ((sint64)wfd.w.nFileSizeHigh << 32);
        mLastWriteDate.mTicks = wfd.w.ftLastWriteTime.dwLowDateTime + ((uint64)wfd.w.ftLastWriteTime.dwHighDateTime << 32);

        attribs = wfd.w.dwFileAttributes;
    }

    mAttributes = VDFileGetAttributesFromNativeW32(attribs);
    return true;
}
Exemple #24
0
VDStringW VDGetFullPath(const wchar_t *partialPath) {
    static tpGetFullPathNameW spGetFullPathNameW = (tpGetFullPathNameW)GetProcAddress(GetModuleHandle("kernel32.dll"), "GetFullPathNameW");

    union {
        char		a[MAX_PATH];
        wchar_t		w[MAX_PATH];
    } tmpBuf;

    if (spGetFullPathNameW && !(GetVersion() & 0x80000000)) {
        LPWSTR p;

        tmpBuf.w[0] = 0;
        DWORD count = spGetFullPathNameW(partialPath, MAX_PATH, tmpBuf.w, &p);

        if (count < MAX_PATH)
            return VDStringW(tmpBuf.w);

        VDStringW tmp(count);

        DWORD newCount = spGetFullPathNameW(partialPath, count, (wchar_t *)tmp.data(), &p);
        if (newCount < count)
            return tmp;

        return VDStringW(partialPath);
    } else {
        LPSTR p;
        VDStringA pathA(VDTextWToA(partialPath));

        tmpBuf.a[0] = 0;
        DWORD count = GetFullPathNameA(pathA.c_str(), MAX_PATH, tmpBuf.a, &p);

        if (count < MAX_PATH)
            return VDStringW(VDTextAToW(tmpBuf.a));

        VDStringA tmpA(count);

        DWORD newCount = GetFullPathNameA(pathA.c_str(), count, (char *)tmpA.data(), &p);
        if (newCount < count)
            return VDTextAToW(tmpA);

        return VDStringW(partialPath);
    }
}
Exemple #25
0
VDStringW VDGetRootVolumeLabel(const wchar_t *rootPath) {
    union {
        char a[MAX_PATH * 2];
        wchar_t w[MAX_PATH];
    } buf;

    DWORD maxComponentLength;
    DWORD fsFlags;
    VDStringW name;

    if (VDIsWindowsNT()) {
        if (GetVolumeInformationW(rootPath, buf.w, vdcountof(buf.w), NULL, &maxComponentLength, &fsFlags, NULL, 0))
            name = buf.w;
    } else {
        if (GetVolumeInformationA(VDTextWToA(rootPath).c_str(), buf.a, vdcountof(buf.a), NULL, &maxComponentLength, &fsFlags, NULL, 0))
            name = VDTextAToW(buf.a);
    }

    return name;
}
Exemple #26
0
uint64 VDFileGetLastWriteTime(const wchar_t *path) {
    if (VDIsWindowsNT()) {
        WIN32_FIND_DATAW fdw;
        HANDLE h = FindFirstFileW(path, &fdw);
        if (h == INVALID_HANDLE_VALUE)
            return 0;

        FindClose(h);

        return ((uint64)fdw.ftLastWriteTime.dwHighDateTime << 32) + fdw.ftLastWriteTime.dwLowDateTime;
    } else {
        WIN32_FIND_DATAA fda;
        HANDLE h = FindFirstFileA(VDTextWToA(path).c_str(), &fda);
        if (h == INVALID_HANDLE_VALUE)
            return 0;

        FindClose(h);

        return ((uint64)fda.ftLastWriteTime.dwHighDateTime << 32) + fda.ftLastWriteTime.dwLowDateTime;
    }
}
void VDUIJobControlDialog::GetJobListDispInfoA(NMLVDISPINFOA *nldi) {
	NMLVDISPINFOW nldiw;

	nldiw.hdr				= nldi->hdr;
    nldiw.item.mask			= nldi->item.mask;
    nldiw.item.iItem		= nldi->item.iItem;
    nldiw.item.iSubItem		= nldi->item.iSubItem;
    nldiw.item.state		= nldi->item.state;
    nldiw.item.stateMask	= nldi->item.stateMask;
    nldiw.item.iImage		= nldi->item.iImage;
    nldiw.item.lParam		= nldi->item.lParam;

	wchar_t bufw[512];
	bufw[0] = 0;
    nldiw.item.pszText		= bufw;
    nldiw.item.cchTextMax	= 512;

	GetJobListDispInfoW(&nldiw);

	VDTextWToA(nldi->item.pszText, nldi->item.cchTextMax, nldiw.item.pszText);
}
Exemple #28
0
void VDSetMenuItemTextByCommandW32(HMENU hmenu, UINT cmd, const wchar_t *text) {
	if (VDIsWindowsNT()) {
		MENUITEMINFOW mmiW;

		mmiW.cbSize		= MENUITEMINFO_SIZE_VERSION_400W;
		mmiW.fMask		= MIIM_TYPE;
		mmiW.fType		= MFT_STRING;
		mmiW.dwTypeData	= (LPWSTR)text;

		SetMenuItemInfoW(hmenu, cmd, FALSE, &mmiW);
	} else {
		MENUITEMINFOA mmiA;
		VDStringA textA(VDTextWToA(text));

		mmiA.cbSize		= MENUITEMINFO_SIZE_VERSION_400A;
		mmiA.fMask		= MIIM_TYPE;
		mmiA.fType		= MFT_STRING;
		mmiA.dwTypeData	= (LPSTR)textA.c_str();

		SetMenuItemInfoA(hmenu, cmd, FALSE, &mmiA);
	}
}
Exemple #29
0
void VDRemoveDirectory(const wchar_t *path) {
    VDStringW::size_type l(wcslen(path));

    if (l) {
        const wchar_t c = path[l-1];

        if (c == L'/' || c == L'\\') {
            VDCreateDirectory(VDStringW(path, l-1).c_str());
            return;
        }
    }

    BOOL succeeded;

    if (!(GetVersion() & 0x80000000)) {
        succeeded = RemoveDirectoryW(path);
    } else {
        succeeded = RemoveDirectoryA(VDTextWToA(path).c_str());
    }

    if (!succeeded)
        throw MyWin32Error("Cannot remove directory: %%s", GetLastError());
}
Exemple #30
0
int VDUIListViewW32::AddItem(const wchar_t *text, uintptr data) {
	DWORD dwMask = LVIF_PARAM | LVIF_TEXT;

	if (mbCheckable)
		dwMask |= LVIF_STATE;

	int item;
	if (VDIsWindowsNT()) {
		LVITEMW lviw={0};

		lviw.mask		= dwMask;
		lviw.iItem		= 0x1FFFFFFF;
		lviw.iSubItem	= 0;
		lviw.state		= 0x1000;
		lviw.stateMask	= (UINT)-1;
		lviw.pszText	= (LPWSTR)text;
		lviw.lParam		= (LPARAM)data;

		item = (int)SendMessageW(mhwnd, LVM_INSERTITEMW, 0, (LPARAM)&lviw);
	} else {
		LVITEMA lvia={0};

		VDStringA textA(VDTextWToA(text));

		lvia.mask		= dwMask;
		lvia.iItem		= 0x1FFFFFFF;
		lvia.iSubItem	= 0;
		lvia.state		= 0x1000;
		lvia.stateMask	= (UINT)-1;
		lvia.pszText	= (LPSTR)textA.c_str();
		lvia.lParam		= (LPARAM)data;

		item = (int)SendMessageA(mhwnd, LVM_INSERTITEMA, 0, (LPARAM)&lvia);
	}

	return item;
}