@akryum/winattr

中文文档
3.0.0发布于 2018/06/19MITCommonJS近 30 天下载 11.4万

Foolproof Windows® file attributes.

原始使用文档
文档目录6 节
  1. Installation
  2. Usage
  3. get(path, callback)
  4. getSync(path)
  5. set(path, attrs, callback)
  6. setSync(path, attrs)

winattr NPM Version Linux Build Windows Build Dependency Status

Foolproof Windows® file attributes for Node.js

Get and set:

  • archive
  • hidden
  • readonly
  • system

… on files and/or directories.

A native binding is used, offering great performance. As a contingency in case that fails, functionality will silently revert to a command line, though it is considerably slower.

Installation

It may go without saying, but this library is not intended to run on anything other than Windows.

Node.js >= 4 is required. To install, type this at the command line:

npm install @akryum/winattr

Or:

yarn add @akryum/winattr

Usage

get(path, callback)

path - Path to file or directory callback(err,attrs) - A callback which is called upon completion

winattr.get("path/to/file.ext", function(err, attrs) {
    if (err == null) console.log(attrs);
});

If you omit the callback, a Promise will be return instead.

getSync(path)

path - Path to file or directory

Returns an Object or throws an error if the file or dir cannot be found/accessed.

var attrs = winattr.getSync("path/to/file.ext");

console.log(attrs);

set(path, attrs, callback)

path - Path to file or directory attrs - An object containing attributes to change callback(err) - A callback which is called upon completion

winattr.set("path/to/folder/", {readonly:true}, function(err) {
    if (err == null) console.log("success");
});

If you omit the callback, a Promise will be return instead.

setSync(path, attrs)

path - Path to file or directory attrs - An object containing attributes to change

Throws an error if the file or dir cannot be found/accessed.

winattr.setSync("path/to/folder/", {readonly:true});

版本与发布记录

@akryum/winattr 共发布 1 个版本,首次发布于 2018/06/19;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.0latest2018/06/198 年前

关于 @akryum/winattr 的常见问题

@akryum/winattr 是什么?

Foolproof Windows® file attributes.

如何安装 @akryum/winattr?

在项目目录运行 npm install @akryum/winattr,或使用 pnpm add / yarn add / bun add。

@akryum/winattr 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/akryum__winattr 是否存在。

@akryum/winattr 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@akryum/winattr 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >= 8。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@akryum/winattr 可以商用吗?

@akryum/winattr 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@akryum/winattr 的下载量有多少?

根据 npm 官方下载统计,@akryum/winattr 在 2026/10/06 – 2026/11/04 这 30 天内被下载 113,706 次,日均约 3,790 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@akryum/winattr 还在维护吗?

最新版本 3.0.0 发布于 2018/06/19(8 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2018/06/19。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。