# undefined FileSystemManager.truncateSync(Object object)

Start from base library version 2.16.1. Please remaining backward compatible.

with Promise style call: Not supported

Mini Program plugin: Support, need to Mini Program base library version no less than 2.19.2

Truncate file contents (truncate The synchronous version of)

# parameter

# Object object

attribute type Default values Required Introductions
filePath string yes File path to truncate (Local path)
length number 0 no Truncate position, default 0. if length Less than the length of the file (bytes), only the front length Four bytes will remain in the file and the rest will be deletedif length Is greater than the file length, it will be expanded, and the extension will be filled with empty bytes0')

# Return value

# undefined

# error

Error code Error message Introductions
fail No such file or directory, open ${filePath} Specified filePath Directory does not exist
fail illegal operation on a directory, open "${filePath}" Specified filePath It's an existing directory.
fail permission denied, open ${dirPath} Specified filePath Path does not have write permissions
fail the maximum size of the file storage limit is exceeded Insufficient storage space
fail sdcard not mounted android sdcard Mount failure

# sample code

const fs = wx.getFileSystemManager()
fs.truncateSync({
  filePath: `${wx.env.USER_DATA_PATH}/hello.txt`, 
  length: 10, // Truncating from the 10th byte
})