Skip to content

Commit

Permalink
Updated the checks for User's Read Permission
Browse files Browse the repository at this point in the history
  • Loading branch information
mateenmohsin committed Jun 5, 2018
1 parent 8d4ac14 commit 9435b12
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion folder-analyzer/analyser.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const path = require('path')
const path = require('path');
const fs = require('fs');


Expand Down Expand Up @@ -103,6 +103,10 @@ function updateFileCounter(filename, fileStatus){

function analyzingDir(startPath){



try{

const files = fs.readdirSync(startPath); //reading the files in that directory.
let filename = null;
let fileStatus = null;
Expand All @@ -122,6 +126,14 @@ function analyzingDir(startPath){
updateFileCounter(filename, fileStatus); //else if its a file, update file counter is called
};
});


}
catch(error){
console.log("Note: Please give the Read Permission to this directory structure,\nor try with the user who has Read Permission to this directory structure!");
process.exit();
}

};


Expand All @@ -137,12 +149,16 @@ function run(currentPath){
analyzingDir(currentPath); //calling analyzing method
const endTime =new Date().getTime(); //getting end time of analyzing

//==Displaying output==//

console.log("\nProcess Time in millisecond: ",endTime-startTime);
console.log(`Found ${totalFiles} files in ${currentPath} within ${dir} folders of size ${convertBytesToMb(dirSize)}mb with`);

Object.keys(results).forEach((key) => {
console.log(`${findPercentage(results[key].count,totalFiles)}% ${key} of size ${convertBytesToMb(results[key].size)}mb (${results[key].count} files)`);
});

//====================//
}

//==End of Main Method RUN ==//
Expand Down

0 comments on commit 9435b12

Please sign in to comment.