windows - Node directory listing with sizes -


I have a flat (a directory) on a Windows 7 server, which I populate with files, and then Everyone needs to get PNG files (name and size) and then the total size I am doing with C #.

  Private Zero CreateManifest () {var dir = new DirectoryInfo (Jobpath); String id; Long size; Fortes (var f in dir.EnumerateFiles ("*. Png")) {id = f.Name.Replace (".png", ""); Size = f.Length; Manifest.files.Add (New FileData (ID, Size)); Manifest.FileCount ++; Manifest.Size + size =; }}  

Since there may be a few thousand files, I need to be fast that I could use the EDE module () to call .NET directly from the node. [If you have tried Edge, then I suggest it. This is a great way to include native .NET C #, F #, and Python in its .NoDeJS project with full ASINC callback support and object marshaling.

Is there a basic NODE technique? And which would be the fastest?

I am tempted to do all the files with a freeidiar and phasstestat (see):

I've also seen something like Directory Walker Program, which can be good:

But what I really need is a fast display on a window box. [Background: This is the processing phase after generation (hair process) 256x256 map of a pyramid of tiles from raw imagery, and the amount of file can be quite large].

Yes, Readier and Elstat is the fastest way I can think. Here's just an extra thing in my example, which has a library named async, which gives us the convenience of running all of our lstat calls in parallel.

  var fs = require ('FS'); // native FS module var async = require ('async'); // async node module (NPM installsync) var manifest = {files: [], size: 0} var directory = __dirname; // Simply give a list of file names in an example / directory fs.readdir (directory, function (mistake, files) {// file to run for each file async.forEach (files, functions (file, callback) ) {/ / File extension (file.substr (file.lastIndexOf (".") == ".png") {// stat file (size is in it) fs.lstat (directory + "/" + File, Function (mistake, data) {// Update our manifest object with new data, manifestize. Size + = data.size; manifest.files.push ({name: file.s Ubstr (0, file.lastIndexOf (".") // file name without .png, size: data.size}); async knows that this file is a callback (error);});} else {// Async knows that this file is called callback ();}}, function (mistake) {// it is said only after all the files that their callback 'console.log (error); console.log (' files' , Manifest.files); console.log ('file number', manifest.files.length); console.log ('total size', manifest.size);});});  

If you have any questions about this code, feel free to ask.


Comments