Skip to content

getAttributes

xiao edited this page Nov 8, 2025 · 1 revision

get attributes of a file or directory.

NOTE: you may wanna use fswin.find for more information about the file or directory

usage

callback:

fswin.getAttributes(path, callback);

async:

var result = await fswin.getAttributesAsync(path);

sync:

var result = fswin.getAttributesSync(path);
  • path is a string specifies the file or directory.
  • callback is a function that takes only one argument result.
  • result is an Object when the path is accessible or null otherwise.

example

var fswin = require('fswin');
var path = 'c:\\';

//sync
var n;
var result = fswin.getAttributesSync(path);
if (result) {
	for (n in result) {
		console.log(n + ': ' + result[n]);
	}
} else {
	console.log(path + ' is inaccessible.');
}

//async
var working = fswin.getAttributes(path, function (result) {
	var n;
	if (result) {
		for (n in result) {
			console.log(n + ': ' + result[n]);
		}
	} else {
		console.log(path + ' is inaccessible.');
	}
});
console.log(working ? 'job queued' : 'failed to queue job');

Clone this wiki locally