当前位置: 首页>>代码示例>>C++>>正文


C++ FilePath::PlatformPath方法代码示例

本文整理汇总了C++中FilePath::PlatformPath方法的典型用法代码示例。如果您正苦于以下问题:C++ FilePath::PlatformPath方法的具体用法?C++ FilePath::PlatformPath怎么用?C++ FilePath::PlatformPath使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FilePath的用法示例。


在下文中一共展示了FilePath::PlatformPath方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: MoveObjectTo

NOINLINE bln Files::MoveObjectTo( const FilePath &sourcePnn, const FilePath &targetPnn, bln is_replace, CError *error )
{
	FilePath source = sourcePnn, target = targetPnn;
	bln result = false;
	CError retError;
	BOOL wapiResult;
	DWORD flags = MOVEFILE_COPY_ALLOWED | MOVEFILE_WRITE_THROUGH;
	if( is_replace )
	{
		flags |= MOVEFILE_REPLACE_EXISTING;
	}

	source.MakeAbsolute();
	target.MakeAbsolute();

	if( !source.IsValid() || !target.IsValid() || source == target )
	{
		retError = Error::InvalidArgument();
		goto toRet;
	}

	wapiResult = ::MoveFileExW( source.PlatformPath(), target.PlatformPath(), flags );
	if( wapiResult != TRUE )
	{
		retError = Error::UnknownError();
		goto toRet;
	}

	result = true;

toRet:
	DSA( error, retError );
	return result;
}
开发者ID:Industrialice,项目名称:StdLib,代码行数:34,代码来源:FilesWindows.cpp

示例2: RemoveFile

NOINLINE bln Files::RemoveFile( const FilePath &pnn, CError *po_error )
{
	CError retError;
	bln funcResult = false;

	if( !Files::IsFile( pnn, &retError ) )  //  will check the pnn
	{
		if( retError == Error::Ok() )
		{
			retError = Error::InvalidArgument();
		}
		goto toExit;
	}

    funcResult = ::DeleteFileW( pnn.PlatformPath() ) != 0;
    if( funcResult == false )
    {
		switch( ::GetLastError() )
		{
		case ERROR_ACCESS_DENIED:
			retError = Error::NoAccess();
			break;
		case ERROR_FILE_NOT_FOUND:
			retError = Error::NoAccess();
			break;
		default:
			retError = Error::UnknownError();
		}
    }

toExit:
	DSA( po_error, retError );
    return funcResult;
}
开发者ID:Industrialice,项目名称:StdLib,代码行数:34,代码来源:FilesWindows.cpp

示例3: CopyObjectTo

bln Files::CopyObjectTo( const FilePath &sourcePnn, const FilePath &targetPnn, bln is_replace, CError *error )
{
	CError retError;
	BOOL result = FALSE;

	if( !sourcePnn.IsValid() || !targetPnn.IsValid() )
	{
		retError = Error::InvalidArgument();
		goto toExit;
	}

	//  TODO: Windows 7, Windows Server 2008 R2, Windows Server 2008, Windows Vista, Windows Server 2003, and Windows XP: Security resource properties for the existing file are not copied to the new file until Windows 8 and Windows Server 2012.
	result = ::CopyFileW( sourcePnn.PlatformPath(), targetPnn.PlatformPath(), is_replace ? FALSE : TRUE );
	if( result == FALSE )
	{
		retError = StdLib_FileError();
	}

toExit:
	DSA( error, retError );
	return result == TRUE;
}
开发者ID:Industrialice,项目名称:StdLib,代码行数:22,代码来源:FilesWindows.cpp

示例4: Open

bln FileCFILEStream::Open( const FilePath &path, FileOpenMode::mode_t openMode, FileProcMode::mode_t procMode, FileCacheMode::mode_t cacheMode, fileError *error )
{
	this->Close();

	bln is_fileExists = Files::IsExists( path );

	if( openMode == FileOpenMode::OpenExisting )
	{
		if( !is_fileExists )
		{
			DSA( error, Error::DoesNotExist() );
			return false;
		}
	}

	if( openMode == FileOpenMode::CreateNew )
	{
		if( is_fileExists )
		{
			DSA( error, Error::AlreadyExists() );
			return false;
		}
	}

	if( openMode == FileOpenMode::CreateAlways )
	{
		if( !(procMode & FileProcMode::Write) )
		{
			DSA( error, fileError( Error::InvalidArgument(), "FileOpenMode::CreateAlways cannot be used without FileProcMode::Write" ) );
			return false;
		}
	}

	TCStr < pathChar > procModeStr;

	if( (procMode & FileProcMode::Read) && (procMode & FileProcMode::Write) )
	{
		procModeStr += is_fileExists ? PLATFORM_PATH( "r+" ) : PLATFORM_PATH( "w+" );
	}
	else if( procMode & FileProcMode::Read )
	{
		procModeStr += PLATFORM_PATH( "r" );
	}
	else
	{
		ASSUME( procMode & FileProcMode::Write );
		procModeStr += PLATFORM_PATH( "w" );
	}

	procModeStr += PLATFORM_PATH( "b" );

	_file = fopen( path.PlatformPath(), procModeStr.CStr() );

	if( !_file )
	{
		DSA( error, fileError( Error::UnknownError(), "fopen has failed" ) );
		return false;
	}

	if( (cacheMode & FileCacheMode::DisableSystemWriteCache) && (procMode & FileProcMode::Write) )
	{
		if( setvbuf( (FILE *)_file, 0, _IONBF, 0 ) != 0 )
		{
			DSA( error, fileError( Error::UnknownError(), "setvbuf has failed, cannot disable caching" ) );
			fclose( (FILE *)_file );
			_file = 0;
			return false;
		}
	}

	_procMode = procMode;
	_openMode = openMode;
	_cacheMode = cacheMode;
	_offsetToStart = 0;
	_bufferSize = 0;
	_customBufferPtr = 0;

	if( FileProcMode::WriteAppend & procMode )
	{
		_offsetToStart = ftell( (FILE *)_file );
		if( _offsetToStart == -1 )
		{
			DSA( error, fileError( Error::UnknownError(), "ftell has failed" ) );
			return false;
		}
	}

	DSA( error, Error::Ok() );
	return true;
}
开发者ID:Industrialice,项目名称:StdLib,代码行数:90,代码来源:FileCFILEStream.cpp

示例5: RemoveFolder

NOINLINE bln Files::RemoveFolder( const FilePath &path, CError *po_error )  //  potentially recursive
{
	uiw len;
	CWStr buf;
    WIN32_FIND_DATAW o_find;
    HANDLE h_find;
	CError o_error;
    bln funcResult = false;
	
	if( !Files::IsFolder( path, &o_error ) )  //  will check the pnn
	{
		if( o_error == Error::Ok() )
		{
			o_error = Error::InvalidArgument();
		}
		goto toExit;
	}

	buf = path.PlatformPath();
	len = buf.Size() + 1;
	buf += L"\\*";

    h_find = ::FindFirstFileW( buf.CStr(), &o_find );
    if( h_find == INVALID_HANDLE_VALUE )
    {
        goto toExit;
    }
    do
    {
        if( !::wcscmp( o_find.cFileName, L"." ) || !::wcscmp( o_find.cFileName, L".." ) )
        {
            continue;
        }

		buf.Resize( len );
		buf += o_find.cFileName;
        if( o_find.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY )
        {
            if( !RemoveFolder( buf.CStr(), po_error ) )
            {
                ::FindClose( h_find );
                goto toExit;
            }
        }
        else if( !RemoveFile( buf.CStr(), po_error ) )
        {
            ::FindClose( h_find );
            goto toExit;
        }
    } while( ::FindNextFileW( h_find, &o_find ) );

    ::FindClose( h_find );

    funcResult = ::RemoveDirectoryW( path.PlatformPath() ) != 0;
    if( !funcResult )
    {
        o_error = Error::UnknownError();
    }

toExit:
    DSA( po_error, o_error );
    return funcResult;
}
开发者ID:Industrialice,项目名称:StdLib,代码行数:63,代码来源:FilesWindows.cpp


注:本文中的FilePath::PlatformPath方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。