lib/probes/FileSyncProbe.js
function(modelId, callback) {
      var t = this,
          dirPath = t.dirPath;

      // Don't allow relative paths
      var fullPath = Path.join(t.dirPath, modelId);
      if (fullPath.indexOf(dirPath) !== 0) {
        return callback({msg: 'Model ID ' + modelId + ' cannot represent a relative path'});
      }

      // See if the path represents a directory
      FS.stat(fullPath, function(error, stats){

        // If this is an existing directory, return a path to dir/index.json
        if (!error && stats.isDirectory()) {
          return t.getFullPath(modelId + '/index', callback);
        }

        // Normal case - return the path & stat to the json file
        fullPath += '.json';
        FS.stat(fullPath, function(error, stats){

          // Not an error if error == ENOENT
          if (error && error.code === 'ENOENT') {
            error = null; stats = null;
          }

          // Process other FS errors
          if (error) {
            return callback({err: error, msg: "Error while observing file: " + fullPath});
          }

          // Forward the callback
          return callback(null, {path: fullPath, stats: stats});
        });
      });
    }
function(modelId, callback) {
      var t = this,
          dirPath = t.dirPath;

      // Don't allow relative paths
      var fullPath = Path.join(t.dirPath, modelId);
      if (fullPath.indexOf(dirPath) !== 0) {
        return callback({msg: 'Model ID ' + modelId + ' cannot represent a relative path'});
      }

      // See if the path represents a directory
      FS.stat(fullPath, function(error, stats){

        // If this is an existing directory, return a path to dir/index.json
        if (!error && stats.isDirectory()) {
          return t.getFullPath(modelId + '/index', callback);
        }

        // Normal case - return the path & stat to the json file
        fullPath += '.json';
        FS.stat(fullPath, function(error, stats){

          // Not an error if error == ENOENT
          if (error && error.code === 'ENOENT') {
            error = null; stats = null;
          }

          // Process other FS errors
          if (error) {
            return callback({err: error, msg: "Error while observing file: " + fullPath});
          }

          // Forward the callback
          return callback(null, {path: fullPath, stats: stats});
        });
      });
    }
function ( modelId , callback ) { var t = this , dirPath = t . dirPath ; // Don't allow relative paths var fullPath = Path . join ( t . dirPath , modelId ) ; if ( fullPath . indexOf ( dirPath ) !== 0 ) { return callback ( { msg : 'Model ID ' + modelId + ' cannot represent a relative path' } ) ; } // See if the path represents a directory FS . stat ( fullPath , function ( error , stats ) { // If this is an existing directory, return a path to dir/index.json if ( ! error && stats . isDirectory ( ) ) { return t . getFullPath ( modelId + '/index' , callback ) ; } // Normal case - return the path & stat to the json file fullPath += '.json' ; FS . stat ( fullPath , function ( error , stats ) { // Not an error if error == ENOENT if ( error && error . code === 'ENOENT' ) { error = null ; stats = null ; } // Process other FS errors if ( error ) { return callback ( { err : error , msg : "Error while observing file: " + fullPath } ) ; } // Forward the callback return callback ( null , { path : fullPath , stats : stats } ) ; } ) ; } ) ; }
Get the full path to the file

This builds the full pathname to the file, and performs an fs.sync()
on that pathname, providing the pathname and sync object in the callback.

@method getFullPath
@param modelId {String} ID of the data model to sync
@param callback {Function(error, return)}
@param callback.error {Object} Error object (null if no error)
@param callback.return {Object} return object
@param callback.return.path {String} Full pathname to the file
@param callback.return.stat {fs.stats} Stats object (null if the file doesn't esixt)
Get the full path to the file