导航:首页 > 文件目录 > UE软件里面文件怎么删除

UE软件里面文件怎么删除

发布时间:2023-07-19 10:31:21

『壹』 UE 文件夹和文件操作

UE有很多针对多平台的操作,其中文件操作也属于跨平台有差异的操作,UE4将跨平台文件封装在FPlatformFileManager::Get().GetPlatformFile()之中

如果没有耐心看细节,只想搬砖就看这里吧
以我的工程myproject为例

先来个常规四件套

CreateDirectoryTree

FPlatformFileManager::Get().GetPlatformFile().CreateDirectoryTree通过调用InternalCreateDirectoryTree,递归的创建所有的目录,就是说,即使父目录不存在,也会生成相应的目录。

CreateDirectory
这个函数在IPlatformFile中没有实现,是由具体的平台子类实现的,也就是说这个函数才是真的创建目录的函数,这个函数在父目录不存在的时候,会返回false。

通过拷贝增加文件夹CopyDirectoryTree
/**

DeleteDirectoryRecursively

DeleteDirectoryRecursively通过FDirectoryVisitor,使用迭代器访问文件夹,然后将文件夹中的文件和文件夹全部删除,这个操作是CreateDirectoryTree的逆操作,不同点在于这个操作同时处理了文件。
这个操作执行之后会自己检查刚才删除的文件夹是否还在,如果不在的话,返回成功,否则返回失败。

DeleteDirectory
对应于CreateDirectory,也没有实现,是由具体的平台子类实现的,同样在删除失败之后会报错。

IterateDirectory

UE4定义了IterateDirectory,这个函数由两个参数,一个是路径,一个是对便利到的路径做操作的Visitor,这个Visitor同样是只有一个接口,具体实现可以自己写。通过Visitor 和IterateDirectory的相互调用实现了递归操作目录的目的。

IterateDirectoryRecursively

IterateDirectoryRecursively遍历文件夹的所有子文件夹,并且通过parallelfor加快了访问速度,在访问中对访问进行写锁定,并通过底层机制是否线程安全选择是否多线程执行,是很不错的便利文件夹的操作,同时这个访问也要求重写访问到指定目录之后需要做的操作,这里只需要执行具体操作就可以了。

这个操作也是由平台子类实现,进行文件存在性检测,如果不存在就返回false

通过拷贝增加文件CopyFile

拷贝文件到指定路径,如果拷贝失败或者目标路径有同名文件,会返回失败

DeleteFile
删除指定的文件,具体实现由平台子类实现

检查是否可以修改IsReadOnly
通过IsReadOnly检查文件是否可以修改,具体实现由平台子类实现

设置是否可以修改SetReadOnly
通过SetReadOnly设置文件是否可以被修改,具体实现由平台子类实现

移动文件位置或者修改文件名称MoveFile
通过MoveFile可以移动文件,如果源路径和目标路径的目录相同,就是修改文件名称了

读取文件类容 OpenRead

/** Attempt to open a file for writing. If successful will return a non-nullptr pointer. Close the file by delete'ing the handle. /
virtual IFileHandle
OpenWrite(const TCHAR Filename, bool bAppend = false, bool bAllowRead = false) = 0;

/**
* Finds all the files within the given directory, with optional file extension filter
* @param Directory The directory to iterate the contents of
* @param FileExtension If FileExtension is NULL, or an empty string "" then all files are found.
* Otherwise FileExtension can be of the form .EXT or just EXT and only files with that extension will be returned.
* @return FoundFiles All the files that matched the optional FileExtension filter, or all files if none was specified.
/
virtual void FindFiles(TArray<FString>& FoundFiles, const TCHAR
Directory, const TCHAR* FileExtension);

/**
* Finds all the files within the directory tree, with optional file extension filter
* @param Directory The starting directory to iterate the contents. This function explores subdirectories
* @param FileExtension If FileExtension is NULL, or an empty string "" then all files are found.
* Otherwise FileExtension can be of the form .EXT or just EXT and only files with that extension will be returned.
* @return FoundFiles All the files that matched the optional FileExtension filter, or all files if none was specified.
/
virtual void FindFilesRecursively(TArray<FString>& FoundFiles, const TCHAR
Directory, const TCHAR* FileExtension);

阅读全文

与UE软件里面文件怎么删除相关的资料

热点内容
app为什么会经常闪退 浏览:66
js怎样获取键盘的高度 浏览:241
怎么生成ico文件 浏览:542
王者荣耀读取文件失败 浏览:611
传奇世界三无版本 浏览:664
上市公司如何建立数据系统 浏览:750
什么都能看的应用app 浏览:452
金蝶软件错误代码3639 浏览:434
dnf90版本狂战左槽 浏览:139
城乡消费水平数据从哪里可以找到 浏览:472
满月微信红包吉利数字 浏览:180
怎样在excel文件中查找 浏览:943
网络公司如何安装网线 浏览:881
小米视频怎么升级失败是怎么回事 浏览:589
苹果开发者客服24小时服务电话 浏览:654
java监听器的应用场景 浏览:322
微信零钱话费多久到账 浏览:165
如何在word做柱状图 浏览:388
一生app是什么功能 浏览:88
制作单文件软件 浏览:692

友情链接