simulator/bin/HubSimulator.js
function ScanGpxDir (gpxdir) {
    var availableRoutes=[];
    var count=0;
    var routesDir = gpxdir;
    var directory = fs.readdirSync(routesDir);
    for (var i in directory) {
        var file = directory [i];
        var route  = path.basename (directory [i],".gpx");
        var name = routesDir + route + '.gpx';
        try {
            if (fs.statSync(name).isFile()) {
                count ++;
                availableRoutes [route] = name;
                console.log ("Found Gpx Route: " + route + " file: " + availableRoutes [route]);
            }
        } catch (err) {/* ignore errors */}
    }
    if (count < 3) {
        console.log ("Find only [%d] GPX file in [%s] please check your directory", count, parsing.opts.gpxdir);
        process.exit (-1);
    }
    return (availableRoutes);
}
function ScanGpxDir (gpxdir) {
    var availableRoutes=[];
    var count=0;
    var routesDir = gpxdir;
    var directory = fs.readdirSync(routesDir);
    for (var i in directory) {
        var file = directory [i];
        var route  = path.basename (directory [i],".gpx");
        var name = routesDir + route + '.gpx';
        try {
            if (fs.statSync(name).isFile()) {
                count ++;
                availableRoutes [route] = name;
                console.log ("Found Gpx Route: " + route + " file: " + availableRoutes [route]);
            }
        } catch (err) {/* ignore errors */}
    }
    if (count < 3) {
        console.log ("Find only [%d] GPX file in [%s] please check your directory", count, parsing.opts.gpxdir);
        process.exit (-1);
    }
    return (availableRoutes);
}
function ScanGpxDir ( gpxdir ) { var availableRoutes = [ ] ; var count = 0 ; var routesDir = gpxdir ; var directory = fs . readdirSync ( routesDir ) ; for ( var i in directory ) { var file = directory [ i ] ; var route = path . basename ( directory [ i ] , ".gpx" ) ; var name = routesDir + route + '.gpx' ; try { if ( fs . statSync ( name ) . isFile ( ) ) { count ++ ; availableRoutes [ route ] = name ; console . log ( "Found Gpx Route: " + route + " file: " + availableRoutes [ route ] ) ; } } catch ( err ) { /* ignore errors */ } } if ( count < 3 ) { console . log ( "Find only [%d] GPX file in [%s] please check your directory" , count , parsing . opts . gpxdir ) ; process . exit ( - 1 ) ; } return ( availableRoutes ) ; }
scan directory and extract all .gpx files
scan directory and extract all . gpx files