Code Monkey home page Code Monkey logo

Comments (26)

kimlimjustin avatar kimlimjustin commented on June 1, 2024 2

Glad to here it, merging the branch into master

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024 1

I think this is a problem because it is implemented via the child process (

Constants.WINDOWS_COMMAND = 'wmic logicaldisk get Caption,FreeSpace,Size,VolumeName,Description /format:list';
).

Thanks for the report tho, I'll try to fix it

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024 1

No, I mean could you please try to pull the utf8_branch and build it from the source (you'll need to install VS C++ tho) and see if it works?

Sorry, but I don't know anything about programming. But if you can make a guide for me, how to build this project, then maybe I can test it.

Ah, I see. However, here's a link to the executable I built, could you please give it a try? https://drive.google.com/file/d/1luqSBsbkD5yE1l-zkI1efB9Tl0HqIuh5/view?usp=sharing

from xplorer.

im-coder-lg avatar im-coder-lg commented on June 1, 2024

Wait, what does Cyrillic mean?

from xplorer.

Nord1cWarr1or avatar Nord1cWarr1or commented on June 1, 2024

Wait, what does Cyrillic mean?

Russian alphabet

from xplorer.

im-coder-lg avatar im-coder-lg commented on June 1, 2024

from xplorer.

Ekristoffe avatar Ekristoffe commented on June 1, 2024

hello guys, instead of doing a copy of node-disk-info code why not using package.json to have it as a dependency ?
A lot of bug have been solved and unless you copy the corrected source code again you won't be able to have the fix and you won't be warned that a new version have been released.
Also there is no versioning available in your Lib folder so nobody know if the code has already been fixed in the source or not.

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

Yep, I'm fixing it rn. The module had a bug at that time and I decided to copy the code to fix it by myself and also some additional features and forgot about it hehe. I'm fixing it rn, will deliver a fix soon!

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

Also, node-disk-info does not support volumename parsing, and this error is because volumename tho...

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

Can't find any solutions right now, I tried the GetVolumeInformationA, marking this issue as help wanted, any PR will be appreciated

from xplorer.

Ekristoffe avatar Ekristoffe commented on June 1, 2024

I remember I had to use this to find the encoding used by the PC and return it as a UTF-8 buffer which after I can change for a string.
Have you try to copy node-disk-info and just add volumename on it ?

        const drives: Drive[] = [];
        let buffer = Utils.execute(Constants.WINDOWS_COMMAND);
        
        const cp = Utils.chcp();
        let encoding = '';
        switch (cp) {
            case '65000': // UTF-7
                encoding = 'UTF-7';
                break;
            case '65001': // UTF-8
                encoding = 'UTF-8';
                break;   
            default: // Other Encoding
                if (/^-?[\d.]+(?:e-?\d+)?$/.test(cp)) {
                    encoding = 'cp' + cp;
                } else {
                    encoding = cp;
                }
        }
        buffer = iconv.encode(iconv.decode(buffer, encoding),'UTF-8');

        const lines = buffer.toString().split('\r\r\n');

On my Japanese PC I can show the volume name in Japanese without trouble.

Filesystem: Removable Disk
Blocks: 8036257792
Used: 20480
Available: 8036237312
Capacity: 0%
Mounted: D:
Name: データ

(this is the output of a modified node-disk-info example command.

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

@Ekristoffe I'm sorry but do you have an example of it?

This time I've tried the latest version of node-disk-info by installing via yarn and edit it inside node_modules and what I got on my computer is ??? instead of データ
image

This is what I've tried

diff --git a/node_modules/node-disk-info/dist/classes/drive.d.ts b/node_modules/node-disk-info/dist/classes/drive.d.ts
index 79e7add..e47c7eb 100644
--- a/node_modules/node-disk-info/dist/classes/drive.d.ts
+++ b/node_modules/node-disk-info/dist/classes/drive.d.ts
@@ -28,6 +28,7 @@ export default class Drive {
      * Indicates the mount point of the disk.
      */
     private readonly _mounted;
+    private readonly _volumename;
     /**
      * Constructor for Drive class.
      *
@@ -38,7 +39,7 @@ export default class Drive {
      * @param {string} capacity Disk capacity.
      * @param {string} mounted Indicates the mount point of the disk.
      */
-    constructor(filesystem: string, blocks: number, used: number, available: number, capacity: string, mounted: string);
+    constructor(filesystem: string, blocks: number, used: number, available: number, capacity: string, mounted: string, volumename:string);
     /**
      * Drive filesystem.
      *
@@ -75,4 +76,5 @@ export default class Drive {
      * @return Gets the mount point of the disk.
      */
     get mounted(): string;
+    get volumename(): string;
 }
diff --git a/node_modules/node-disk-info/dist/classes/drive.js b/node_modules/node-disk-info/dist/classes/drive.js
index 9d13d32..7f4dcfb 100644
--- a/node_modules/node-disk-info/dist/classes/drive.js
+++ b/node_modules/node-disk-info/dist/classes/drive.js
@@ -16,13 +16,14 @@ var Drive = /** @class */ (function () {
      * @param {string} capacity Disk capacity.
      * @param {string} mounted Indicates the mount point of the disk.
      */
-    function Drive(filesystem, blocks, used, available, capacity, mounted) {
+    function Drive(filesystem, blocks, used, available, capacity, mounted, volumename=null) {
         this._filesystem = filesystem;
         this._blocks = blocks;
         this._used = used;
         this._available = available;
         this._capacity = capacity;
         this._mounted = mounted;
+        this._volumename = volumename
     }
     Object.defineProperty(Drive.prototype, "filesystem", {
         /**
@@ -96,6 +97,18 @@ var Drive = /** @class */ (function () {
         enumerable: false,
         configurable: true
     });
+    Object.defineProperty(Drive.prototype, "volumename", {
+        /**
+         * Indicates the mount point of the disk.
+         *
+         * @return Gets the mount point of the disk.
+         */
+        get: function () {
+            return this._volumename;
+        },
+        enumerable: false,
+        configurable: true
+    });
     return Drive;
 }());
 exports.default = Drive;
diff --git a/node_modules/node-disk-info/dist/platforms/windows.js b/node_modules/node-disk-info/dist/platforms/windows.js
index 303bd1d..6762154 100644
--- a/node_modules/node-disk-info/dist/platforms/windows.js
+++ b/node_modules/node-disk-info/dist/platforms/windows.js
@@ -41,11 +41,13 @@ var Windows = /** @class */ (function () {
         }
         buffer = iconv_lite_1.default.encode(iconv_lite_1.default.decode(buffer, encoding), 'UTF-8');
         var lines = buffer.toString().split('\r\r\n');
+        console.log(lines)
         var newDiskIteration = false;
         var caption = '';
         var description = '';
         var freeSpace = 0;
         var size = 0;
+        var volumename = ''
         lines.forEach(function (value) {
             if (value !== '') {
                 var tokens = value.split('=');
@@ -65,6 +67,9 @@ var Windows = /** @class */ (function () {
                     case 'Size':
                         size = isNaN(parseFloat(data)) ? 0 : +data;
                         break;
+                    case 'VolumeName':
+                        volumename = data;
+                        break;
                 }
             }
             else {
@@ -74,7 +79,7 @@ var Windows = /** @class */ (function () {
                     if (size > 0) {
                         percent = Math.round((used / size) * 100) + '%';
                     }
-                    var d = new drive_1.default(description, size, used, freeSpace, percent, caption);
+                    var d = new drive_1.default(description, size, used, freeSpace, percent, caption, volumename);
                     drives.push(d);
                     newDiskIteration = false;
                     caption = '';
diff --git a/node_modules/node-disk-info/dist/utils/constants.js b/node_modules/node-disk-info/dist/utils/constants.js
index d2936e1..52b0d4c 100644
--- a/node_modules/node-disk-info/dist/utils/constants.js
+++ b/node_modules/node-disk-info/dist/utils/constants.js
@@ -10,7 +10,7 @@ var Constants = /** @class */ (function () {
     /**
      * Command to execute on Windows.
      */
-    Constants.WINDOWS_COMMAND = 'wmic logicaldisk get Caption,FreeSpace,Size,VolumeSerialNumber,Description  /format:list';
+    Constants.WINDOWS_COMMAND = 'wmic logicaldisk get Caption,FreeSpace,Size,VolumeSerialNumber,Description,VolumeName  /format:list';
     /**
      * Command to execute on Linux.
      */

Also, if you could please support this directly from node-disk-info, it would be much helpful.

Sorry for keep disturbing you.

Thanks and Regards

from xplorer.

Ekristoffe avatar Ekristoffe commented on June 1, 2024

Hello I have published my changes on this:
https://github.com/Ekristoffe/node-disk-info/tree/TestName
It is a quick and dirty test so only windows system and the names could be better

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

image
@Ekristoffe It shows ??? too while this is the real name:
image

Is it because my system is incompatible (but I don't think so, I got an i7 with 32GB of ram)

Or @Nord1cWarr1or could you please give it a try?

from xplorer.

Ekristoffe avatar Ekristoffe commented on June 1, 2024

what is the output of the command (in cmd):
chcp
wmic logicaldisk get Caption,VolumeName /format:list
thanks.

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

what is the output of the command (in cmd): chcp wmic logicaldisk get Caption,VolumeName /format:list thanks.

chcp

Active code 65001

wmic logicaldisk get Caption,VolumeName /format:list

Caption=C:
VolumeName=Windows 10


Caption=D:
VolumeName=System Reserved


Caption=E:
VolumeName=Program


Caption=F:
VolumeName=Data


Caption=G:
VolumeName=OS


Caption=H:
VolumeName=New Volume


Caption=I:
VolumeName=??

from xplorer.

Ekristoffe avatar Ekristoffe commented on June 1, 2024

Indeed your pc can't handle the non latin char it seem (i think it is more a windows problem since linux is always using UTF8) ...
I am interested by @Nord1cWarr1or could you also try the chcp and wmic command ?

from xplorer.

Nord1cWarr1or avatar Nord1cWarr1or commented on June 1, 2024

@Ekristoffe, yes.
chcp

Текущая кодовая страница: 866 

wmic logicaldisk get Caption,VolumeName /format:list

Caption=C:
VolumeName=


Caption=D:
VolumeName=Зарезервировано системой


Caption=E:
VolumeName=


Caption=F:
VolumeName=


Caption=H:
VolumeName=Новый том

from xplorer.

Ekristoffe avatar Ekristoffe commented on June 1, 2024

Hello, The fix should work without any problem as long as windows is using the right codepage.

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

Erm, it's probably my computer problem (but I am sure there're many people with the same problem as me),

I think I'll commit the volume name feat here to support those people like @Nord1cWarr1or .

The code will first check if the volumename property is valid (not ???), if it's valid, the code will display the volumename, otherwise display the filesystem.

Maybe this is the best approach for now.

I'll open a PR for this issue soon later (as soon as I can use my computer), will you be able to help me test(review) it? @Nord1cWarr1or or @Ekristoffe

Thanks and best regards

from xplorer.

Nord1cWarr1or avatar Nord1cWarr1or commented on June 1, 2024

I'll open a PR for this issue soon later (as soon as I can use my computer), will you be able to help me test(review) it? @Nord1cWarr1or or @Ekristoffe

Sure. Test build will be at Actions, right?

from xplorer.

kimlimjustin avatar kimlimjustin commented on June 1, 2024

I'll open a PR for this issue soon later (as soon as I can use my computer), will you be able to help me test(review) it? @Nord1cWarr1or or @Ekristoffe

Sure. Test build will be at Actions, right?

No, I mean could you please try to pull the utf8_branch and build it from the source (you'll need to install VS C++ tho) and see if it works?

from xplorer.

im-coder-lg avatar im-coder-lg commented on June 1, 2024

I think I have some code for this. Get Git for the cloning process and you know how to build it after that.

$ git clone https://github.com/kimlimjustin/xplorer.git
$ git checkout utf8_branch

Then you can start the build process.
Edit: Works on all OSes, you need the programs basically.

from xplorer.

Nord1cWarr1or avatar Nord1cWarr1or commented on June 1, 2024

No, I mean could you please try to pull the utf8_branch and build it from the source (you'll need to install VS C++ tho) and see if it works?

Sorry, but I don't know anything about programming.
But if you can make a guide for me, how to build this project, then maybe I can test it.

from xplorer.

Nord1cWarr1or avatar Nord1cWarr1or commented on June 1, 2024

@kimlimjustin I just installed it, and it works as expected.

image

from xplorer.

Nord1cWarr1or avatar Nord1cWarr1or commented on June 1, 2024

fixed via #144

from xplorer.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.