Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to make a file indexer by node.js. The program is supposed to index files and folders in an array and also check inside folders and add all sub folders and files

I wrote:

JavaScript
fs.readdir(__dirname,index);
function index(err,data){
 for (i in data){
        if(fs.statSync(data[i]).isDirectory()){
            j.folders.push(path.resolve(data[i]));
            fs.readdir(data[i],index);
        }
        else{
            j.files.push(path.resolve(data[i]));
        }
    }
} 

... this code, but when it passes inside a folder it gives traceback and stops executing.

ps. please don't comment about walk, I want to write my own module.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900