예제 #1
0
VError XLinuxFile::Copy(const VFilePath& inDestination, VFile** outFile, FileCopyOptions inOptions ) const
{
	VFilePath tmpPath(inDestination);
	
	if(tmpPath.IsFolder())
	{
		VStr255 name;					//jmo - todo : NAME_MAX ?
		fOwner->GetName(name);
		tmpPath.SetFileName(name);
	}

 	PathBuffer dstPath;
 	dstPath.Init(tmpPath);

	CopyHelper cpHlp;
	return cpHlp.Copy(fPath, dstPath);
}
예제 #2
0
VError XLinuxFile::Move(const VFilePath& inDestinationPath, VFileSystem *inDestinationFileSystem, VFile** outFile, FileCopyOptions /*inOptions*/) const
{
	VFilePath dstPath(inDestinationPath);

	if (dstPath.IsFolder())
	{
		VStr255 name;					//jmo - todo : NAME_MAX ?
		fOwner->GetName(name);
		dstPath.SetFileName(name);
	}

	PathBuffer pathBuffer;
	pathBuffer.Init(dstPath);

	//First we try to rename the file...
	VError verr;
	{
		RenameHelper rnmHlp;
		verr=rnmHlp.Rename(fPath, pathBuffer);
	}

	//If Rename() fails because src and dst are not on the same fs, we try a Copy()
	if(verr!=VE_OK && IS_NATIVE_VERROR(verr) && NATIVE_ERRCODE_FROM_VERROR(verr)==EXDEV)
	{
		CopyHelper cpHlp;
		verr = cpHlp.Copy(fPath, pathBuffer);

		// it's a move not a copy, so one must delete the source after a sucessful copy
		if (verr == VE_OK)
		{
			int res=unlink(fPath.GetPath());
			verr = (res==0) ? VE_OK :  MAKE_NATIVE_VERROR(errno);
		}
	}

	if (outFile != NULL)
	{
		*outFile = (verr == VE_OK) ? new VFile( dstPath, inDestinationFileSystem) : NULL;
	}

	return verr;
}
예제 #3
0
VError XLinuxFile::Copy(const VFilePath& inDestination, VFileSystem *inDestinationFileSystem, VFile** outFile, FileCopyOptions /*inOptions*/) const
{
	VFilePath dstPath(inDestination);

	if(dstPath.IsFolder())
	{
		VStr255 name;					//jmo - todo : NAME_MAX ?
		fOwner->GetName(name);
		dstPath.SetFileName(name);
	}

	PathBuffer pathBuffer;
	pathBuffer.Init(dstPath);

	CopyHelper cpHlp;
	VError err = cpHlp.Copy(fPath, pathBuffer);

	if (outFile != NULL)
	{
		*outFile = (err == VE_OK) ? new VFile( dstPath, inDestinationFileSystem) : NULL;
	}

	return err;
}