Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
xxoo committed Aug 29, 2024
1 parent 4271d66 commit 89ec0dc
Show file tree
Hide file tree
Showing 20 changed files with 344 additions and 303 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fswin",
"version": "3.24.524",
"version": "3.24.829",
"description": "nodejs fs extensions for windows",
"main": "index.js",
"types": "index.d.ts",
Expand Down
47 changes: 46 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,51 @@
[`fswin`](https://www.npmjs.com/package/fswin) is a native [`node.js`](http://nodejs.org) add-on that works on windows.
It has ported some platform specified filesystem APIs. And made them easy to use in javascript.

For details and examples please see [wiki](https://github.com/xxoo/node-fswin/wiki)
For api documents and examples please see [wiki](https://github.com/xxoo/node-fswin/wiki)

NOTE: fswin depends on n-api since v3. which requires node.js v8 or later.

## How to Install

You may install fswin by using the following command line:

```
npm install fswin
```

The package contains prebuilt binaries for `node.js`, `electron` and `nw.js` on all architectures.

## How to Build

first you need to install [Visual Studio](http://www.visualstudio.com) 2019 or later.

then you need to install [Python](https://www.python.org/downloads/windows)

then you need to install node-gyp

```
npm -g install node-gyp
```

then you need to clone the repo

```
git clone https://github.com/xxoo/node-fswin.git
cd node-fswin
```

finally you can build the source

for `node.js`:

```
node-gyp rebuild
```

for `electron`:

```
node-gyp rebuild --target=x.x.x --dist-url=https://atom.io/download/electron
```

for `nw.js` please follow the [official document](https://nwjs.readthedocs.io/en/latest/For%20Users/Advanced/Use%20Native%20Node%20Modules/)
22 changes: 11 additions & 11 deletions src/convertPath.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

class convertPath {
public:
static wchar_t *func(const wchar_t *path, bool islong) {//you need to delete the result yourself if it is not NULL
wchar_t *tpath;
static wchar_t* func(const wchar_t* path, bool islong) {//you need to delete the result yourself if it is not NULL
wchar_t* tpath;
DWORD sz = islong ? GetLongPathNameW(path, NULL, 0) : GetShortPathNameW(path, NULL, 0);
if (sz > 0) {
tpath = new wchar_t[sz];
Expand All @@ -24,9 +24,9 @@ class convertPath {
napi_async_work work;
napi_ref self;
napi_ref cb;
wchar_t *path;
wchar_t* path;
bool islong;
wchar_t *result;
wchar_t* result;
};
static napi_value sync(napi_env env, napi_callback_info info) {
napi_value result;
Expand All @@ -46,14 +46,14 @@ class convertPath {
napi_coerce_to_string(env, argv[0], &tmp);
napi_get_value_string_utf16(env, tmp, NULL, 0, &str_len);
str_len += 1;
wchar_t *str = new wchar_t[str_len];
wchar_t* str = new wchar_t[str_len];
napi_get_value_string_utf16(env, tmp, (char16_t*)str, str_len, NULL);
bool islong = false;
if (argc > 1) {
napi_coerce_to_bool(env, argv[1], &tmp);
napi_get_value_bool(env, tmp, &islong);
}
wchar_t *s = func(str, islong);
wchar_t* s = func(str, islong);
delete[]str;
if (s) {
napi_create_string_utf16(env, (char16_t*)s, wcslen(s), &result);
Expand All @@ -79,7 +79,7 @@ class convertPath {
napi_valuetype t;
napi_typeof(env, argv[1], &t);
if (t == napi_function) {
cbdata *data = new cbdata;
cbdata* data = new cbdata;
data->islong = false;
size_t str_len;
napi_value tmp;
Expand Down Expand Up @@ -114,12 +114,12 @@ class convertPath {
}
return result;
}
static void execute(napi_env env, void *data) {
cbdata *d = (cbdata*)data;
static void execute(napi_env env, void* data) {
cbdata* d = (cbdata*)data;
d->result = func(d->path, d->islong);
}
static void complete(napi_env env, napi_status status, void *data) {
cbdata *d = (cbdata*)data;
static void complete(napi_env env, napi_status status, void* data) {
cbdata* d = (cbdata*)data;
delete[]d->path;
napi_value cb, self, argv;
napi_get_reference_value(env, d->cb, &cb);
Expand Down
Loading

0 comments on commit 89ec0dc

Please sign in to comment.