Skip to main content
Version: v2

closeSync

Start from API_LEVEL 2.0 . Please refer to API_LEVEL.

Close the file handle synchronously.

Type

function closeSync(option: Option): Result

Simplified calling method

function closeSync(fd: number): Result

Parameters

Option

PropertyTypeRequiredDefaultValueDescriptionAPI_LEVEL
fdnumberY-File handle, returned by the openSync, openAssetsSync and other APIs2.0

Result

TypeDescription
numberIf 0 is returned, success is indicated

Example

import { openSync, closeSync, O_RDONLY } from '@zos/fs'

const fd = openSync({
path: 'test.txt',
flag: O_RDONLY,
})
const result = closeSync({
fd,
})

if (result === 0) {
console.log('file descriptor closed')
}