Resolve a file name into an absolute path Async if called with a cb, synchronous if not
358325
function resolveFile(baseDirs, addType, fileName, type, cb)
{
  // The label this file will have in the output
  // For hbs views, this is the name that it will be save as into the template array.
  var label = pathlib.basename(fileName);

  // Label can be overridden with entries of the form: "label:file-name-or-path"
  var idx = fileName.indexOf(':');
  if ( idx > 0 )
  {
    label = fileName.substr(0,idx);
    fileName = fileName.substr(idx+1);
  }

  // Construct a list of paths to check
  var paths = [];
  baseDirs.forEach(function(baseDir) {
    if ( addType )
      baseDir += '/'+type;

    // Search for exact filename
    paths.push(pathlib.resolve(baseDir,fileName));

    // And with the type as an extension
    paths.push(pathlib.resolve(baseDir,fileName+'.'+type));

    // Special case 'view' because it used to mean hbs
    if ( type == 'view' )
    {
      VIEW_TYPES.forEach(function(altType) {
        paths.push(pathlib.resolve(baseDir,fileName+'.'+altType));
      });
    }
  });

  // Async
  if ( cb )
  {
    async.detectSeries(paths, fs.exists, function(result) {
      if ( result )
        return cb(undefined, label+':'+result);
      else
        return cb(new Error(errStr));
    });
  }
  else
  {
    // Sync
    for ( i=0 ; i < paths.length ; i++ )
    {
      if ( fs.existsSync(paths[i]) )
      {
        return label+':'+paths[i];
      }
    }

    throw new Error('Unable to find source ' + type + ' file for ' + fileName + ' in ' + paths.join(', '));
  }
}
513897
def get_abspath(path, content_dir=CONTENT_DIR):
    
    if path:
        file = re.search('content://(.+)', path)
        if file:
            return os.path.join(content_dir, file.group(1))
    return path
301488
def _absolute_path(path, relative_to=None):
    '''
    
    '''

    if path and os.path.isabs(path):
        return path
    if path and relative_to is not None:
        _abspath = os.path.join(relative_to, path)
        if os.path.isfile(_abspath):
            log.debug(
                'Relative path \'%s\' converted to existing absolute path '
                '\'%s\'', path, _abspath
            )
            return _abspath
    return path
43455
function(filename){
    // resolve by symlink if possible
    for (var from in this.symlinks)
      if (filename.indexOf(from) === 0 && (filename === from || filename[from.length] === '/'))
        return this.symlinks[from] + filename.substr(from.length);

    return path.resolve(this.fsBaseURI, filename.replace(/^[\\\/]/, ''));
  }
792455
function File(from, to) {
	var cached, dirname, external, local, source, resolved;

	resolved = _resolve(from, to);

	if (cached = cache[resolved]) {
		return cached;
	}

	if (!fs.existsSync(resolved)) {
		throw new Error('File "' + resolved + '" not found');
	}

	this.path = resolved;

	dirname = path.dirname(resolved);
	local = this.local = {};
	external = this.external = [];
	source = this.source = fs.readFileSync(resolved);

	each(detective(source), function(to) {
		if (~to.indexOf('/')) {
			local[to] = _resolve(dirname, to)
		}
		else {
			external.push(to);
		}
	});

	cache[resolved] = this;
}
997946
function findSync(dir, callback) {
	var rootStat = fs.statSync(dir);
	if (!rootStat.isDirectory()) {
		if (callback) callback(dir, rootStat);
		return [dir];
	}

	return fs.readdirSync(dir).reduce(function(files, file) {
		var p = path.join(dir, file),
			stat = fs.statSync(p);
		if (callback) callback(p, stat);
		files.push(p);

		if (stat.isDirectory()) {
			files.push.apply(files, findSync(p, callback));
		}

		return files;
	}, []);
}
780568
function resolvePath(path, options, callback) {
        if (!callback) {
            callback = options;
            options = {};
        }
        
        var alreadyRooted = options.alreadyRooted;
        var checkSymlinks = options.checkSymlinks === undefined 
            ? true : options.checkSymlinks;
        var isHome        = false;
        
        if (checkSymlinks === undefined)
            checkSymlinks = true;
        if (path.substr(0, 2) == "~/") {
            isHome = true;
            path = process.env.HOME + path.substr(1);
        }
        else if (!alreadyRooted) 
            path = join(root, path);

        if (checkSymlinks && fsOptions.checkSymlinks && !alreadyRooted) 
            fs.realpath(path, check);
        else check(null, path);

        function check(err, path) {
            if (err) return callback(err);
            
            if (!options.nocheck) {
                if (!(path === base || path.substr(0, root.length) === root)
                  && !isHome) {
                    err = new Error("EACCESS: '" + path + "' not in '" + root + "'");
                    err.code = "EACCESS";
                    return callback(err);
                }
            }
            callback(null, path);
        }
    }
602881
function getFilePath(sourcePath, filename, subDir) {
    if (subDir === void 0) { subDir = ''; }
    var filePath = filename
        .replace(path.resolve(sourcePath), '')
        .replace(path.basename(filename), '');
    if (subDir) {
        filePath = filePath.replace(subDir + path.sep, '');
    }
    if (/^[\/\\]/.test(filePath)) {
        filePath = filePath.substr(1);
    }
    return filePath.replace(/\\/g, '/');
}
428744
function writeFileSync (filename, content, options) {
  if (typeof filename !== 'string') {
    throw new Error('path must be a string')
  }

  mkdirp.sync(path.dirname(filename))
  fs.writeFileSync(filename, content, options)
}
462134
def resolve_path(self, filename, skip='', skip_original='',
                     default_template=None):
        
        def _file(filename, dirs):
            for d in dirs:
                _f = os.path.normpath(os.path.join(d, filename))
                if os.path.exists(_f):
                    yield _f
            raise StopIteration

        filename = os.path.normpath(filename)
        skip = os.path.normpath(skip)
        skip_original = os.path.normpath(skip_original)

        if os.path.exists(filename):
            return filename

        if filename and self.dirs:
            _files = _file(filename, self.dirs)
            if skip_original == filename:
                for f in _files:
                    if f == skip:
                        break

            for f in _files:
                if f != skip:
                    return f
                else:
                    continue

        if default_template:
            if not isinstance(default_template, (tuple, list)):
                default_template = [default_template]
            for x in default_template:
                filename = self.resolve_path(x)
                if filename:
                    return filename
56899
function resolveAsync(p, base, root) {
  if (!path.isAbsolute(p)) {
    return new Promise(function(r, j) {
      resolve(forceRelative(p), {
        basedir: path.resolve(root, base)
      }, function(err, res) {
        if (err) {
          j(err);
        } else {
          r(res);
        }
      });
    });

  } else {

    return Promise.resolve(p);
  }
}
169044
function readSync( path, options ) {
	var file,
		opts;

	if (
		arguments.length > 1 &&
		!isString( options )
	) {
		opts = options;
	} else {
		opts = {};
	}
	opts.encoding = 'utf8';
	file = readFile.sync( path, opts );
	if ( file instanceof Error ) {
		return file;
	}
	return parse( file, opts );
}
470192
function (fnCallbackAsyncL1) {

            async.whilst(
                function () {
                    return aArtifactsSyncWork.length > 0;
                },
                function (fnCallbackAsyncL2) {
                    var oItem = aArtifactsSyncWork.shift();

                    switch (oItem.type) {
                        case util.OBJECT_TYPE.folder:
                            me.syncFolder(oItem.id, oItem.modif, fnCallbackAsyncL2);
                            break;

                        case util.OBJECT_TYPE.file:
                            me.syncFile(oItem.id, oItem.modif, sCwd, fnCallbackAsyncL2);
                            break;
                    }

                },
                function (oError, oResult) {
                    fnCallbackAsyncL1(oError, oResult);
                }
            );
        }
348009
function resolveFile(success, fail, request, options) {
    var path = request.substring(7);
    resolve(success, fail, path, window.PERSISTENT, UNSANDBOXED, options);
}
1345976
function resolve(val, i, isPath) {
			val = val.replace('~', '');
			return Promise.resolve(System.normalize(val))
					.then(function(normalized) {
						return System.locate({name: normalized, metadata: {}});
					})
					.then(function(address) {
						if (isPath) {
							options.includePaths.push(
									path.resolve(address.replace('file:', '').replace('.js', ''))
							);
						} else {
							var originalRelativePath      = path.relative(
									path.dirname(file.path),
									path.resolve(address.replace('file:', '').replace('.js', ''))
							);
							var originalRelativePathArray = originalRelativePath.split(path.sep);

							replacements[i] = path.posix?
									path.posix.join.apply(this, originalRelativePathArray):
									path.normalize(originalRelativePath).replace(/\\/g, '/').replace('//', '/');
						}
					});
		}
679934
function (p, cb) {
				var pth = p.replace(/\\\?/g, '\/'); // Glob must use / as path seperator even on windows
				glob(pth + '/**/*.*', function (er, files) {
					if (er) {
						return cb(er);
					}
					return cb(null, files.map(function (f) {
						return path.relative(p, f);
					}));
				});
			}
897887
function(callback){
    var argFiles,
        filePath,
        i;

    if(!program.files || program.files.length === 0){
        return callback(null, true);
    }

    argFiles = program.files.split(',');

    output("Loading files...");

    for(i=0; i<argFiles.length; i++){
        filePath = path.resolve(__dirname, argFiles[i].toString());
        output("Reading file..." + filePath);
        if(fs.existsSync(filePath)){
            files.push(fs.readFileSync(filePath));
        }else{
            return callback("File does not exist, " + filePath, false);
        }
    }

    callback(null, true);
}