Exemplo n.º 1
0
VError XLinuxFile::Rename(const VFilePath& inDstPath, VFile** outFile) const
{
	if(outFile!=NULL)
		*outFile=NULL;

	PathBuffer dstPath;
	dstPath.Init(inDstPath);
	
	RenameHelper rnmHlp;
	VError verr=rnmHlp.Rename(fPath, dstPath);

	if(verr==VE_OK && outFile!=NULL)
		*outFile=new VFile(inDstPath);

    return verr;
}
Exemplo n.º 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;
}
Exemplo n.º 3
0
VError XLinuxFile::Rename(const VString& inName, VFile** outFile) const
{
	//jmo - todo : we should check that inName < NAME_MAX or use PathBuffer

	VFilePath newPath(fOwner->GetPath());
	newPath.SetFileName(inName);

	PathBuffer dstPath;
	dstPath.Init(newPath);

	RenameHelper rnmHlp;
	VError verr=rnmHlp.Rename(fPath, dstPath);

	if (outFile != NULL)
	{
		*outFile = (verr == VE_OK) ? new VFile( newPath, fOwner->GetFileSystem()) : NULL;
	}

	return verr;
}