Exemple #1
0
BOOL CFileManip::Ren(LPCTSTR lpSource, LPCTSTR lpDestination, BOOL bHidePrompt)
{
	TCHAR szSource[MAX_PATH + 2] = _T("");
	TCHAR szDestination[MAX_PATH + 2] = _T("");
	::_tcsncpy(szSource, lpSource, MAX_PATH);
	::_tcsncpy(szDestination, lpDestination, MAX_PATH);

	// Ren should not be able to affect any directories, just like
	// how "ren" works in DOS. If need to rename directories, use 
	// Move instead.
	if (Existence(szSource) == FM_DIRECTORY)
	{
		::SetLastError(ERR_DIRECTORY);
		return FALSE;
	}

	SHFILEOPSTRUCT fs;
	::memset(&fs, 0, sizeof(SHFILEOPSTRUCT));

	fs.pFrom = szSource;
	fs.pTo = szDestination;
	fs.wFunc = FO_RENAME;
	fs.fFlags = FOF_FILESONLY;
	
	if (bHidePrompt)
		fs.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);

	return (::SHFileOperation(&fs) == 0);
}
Exemple #2
0
/////////////////////////////////////////////////////////////////
// File-level operations
/////////////////////////////////////////////////////////////////
BOOL CFileManip::Copy(LPCTSTR lpSource, LPCTSTR lpDestination, BOOL bHidePrompt)
{
	// Enlightened by jbarton on Codeproject.com:
	// SHFileOperation expects character strings with "double-null terminators",
	// thus LPCTSTR's that are passed in as parameters cannot be directly used
	// by SHFileOperation. We need to duplicate the strings in order to make sure
	// that they are "double-null terminated".
	TCHAR szSource[MAX_PATH + 2] = _T("");
	TCHAR szDestination[MAX_PATH + 2] = _T("");
	::_tcsncpy(szSource, lpSource, MAX_PATH);
	::_tcsncpy(szDestination, lpDestination, MAX_PATH);

	// Copy should not be able to affect any directories, just like
	// how "copy" works in DOS. If need to copy directories, use 
	// XCopy instead.
	if (Existence(szSource) == FM_DIRECTORY)
	{
		::SetLastError(ERR_DIRECTORY);
		return FALSE;
	}

	SHFILEOPSTRUCT fs;
	::memset(&fs, 0, sizeof(SHFILEOPSTRUCT));

	fs.pFrom = szSource;
	fs.pTo = szDestination;
	fs.wFunc = FO_COPY;
	fs.fFlags = FOF_FILESONLY;

	if (bHidePrompt)
		fs.fFlags |= (FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR);

	// This does the real job...
	return (::SHFileOperation(&fs) == 0);
}
BOOL DUI_RadioGroup::Destroy()
{
	if (Existence())
	{
		delete m_IDs;
		return TRUE;
	}
	return FALSE;
}
Exemple #4
0
QByteArray QFileIOService::ExecuteRDSCommand(QRDSServer &rdsserver, quint8 command, const QMap<QString, QString> &map)
{
    QByteArray ret;

    switch (command)
    {
    case QBrowseDirCommand:
        return BrowseDir(rdsserver, map);
        break;
    case QFileReadCommand:
        return FileRead(rdsserver, map);
        break;
    case QFileWriteCommand:
        return FileWrite(rdsserver, map);
        break;
    case QFileRenameCommand:
        return FileRename(rdsserver, map);
        break;
    case QFileRemoveFileCommand:
        return FileRemove(rdsserver, map, true);
        break;
    case QFileRemoveDirectoryCommand:
        return FileRemove(rdsserver, map, false);
        break;
    case QFileExistCommand:
        return Existence(rdsserver, map);
        break;
    case QFileCreateDirCommand:
        return CreateDir(rdsserver, map);
        break;
    case QFileGetRootDirCommand:
        return GetRootDir(rdsserver);
        break;
    }

    return ret;
}