renameSync
Start from API_LEVEL
2.0. Please refer to API_LEVEL.
Rename the files in the /data directory of the Mini Program, renaming the files from oldPath to newPath.
Type
function renameSync(option: Option): Result
Parameters
Option
| Property | Type | Required | DefaultValue | Description | API_LEVEL |
|---|---|---|---|---|---|
| oldPath | string | Y | - | Old path | 2.0 |
| newPath | string | Y | - | New path | 2.0 |
Result
| Type | Description |
|---|---|
number | If 0 is returned, success is indicated |
Example
import { renameSync } from '@zos/fs'
const result = renameSync({
oldPath: 'test.txt',
newPath: 'new_test.txt',
})
if (result === 0) {
console.log('renameSync success')
}