add: rename() in files module
This commit is contained in:
@@ -81,14 +81,16 @@
|
||||
|
||||
复制文件。例如`files.copy("/sdcard/1.txt", "/sdcard/Download/1.txt")`。
|
||||
|
||||
### files.move(fromPath, toPath)
|
||||
|
||||
移动文件,返回是否移动成功。例如`files.rename("/sdcard/1.txt", "/sdcard/Download/1.txt")`会把1.txt文件从sd卡根目录移动到Download文件夹。
|
||||
|
||||
### files.rename(path, newName)
|
||||
* path \<String\> 要重命名的原文件路径
|
||||
* newName \<String\> 要重命名的新文件名
|
||||
|
||||
重命名文件,并返回是否重命名成功。例如`files.rename("/sdcard/1.txt", "2.txt")`。
|
||||
|
||||
也可以用作文件移动,例如`files.rename("/sdcard/1.txt", "/sdcard/Download/1.txt")`会把1.txt文件从sd卡根目录移动到Download文件夹。
|
||||
|
||||
### files.renameWithoutExtension(path, newName)
|
||||
* path \<String\> 要重命名的原文件路径
|
||||
* newName \<String\> 要重命名的新文件名
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SharedPrefScriptFileList extends ScriptFileList {
|
||||
public void rename(int position, String newName, boolean renameFile) {
|
||||
mScriptName.set(position, newName);
|
||||
if (renameFile) {
|
||||
String newPath = PFile.renameWithoutExtension(mScriptPath.get(position), newName);
|
||||
String newPath = PFile.renameWithoutExtensionAndReturnNewPath(mScriptPath.get(position), newName);
|
||||
mScriptPath.set(position, newPath);
|
||||
}
|
||||
syncWithSharedPref();
|
||||
|
||||
Reference in New Issue
Block a user