/user1-orionContent/test/testfile  -> /us/user1/orionContent/test
549298
function getRealLocation(filepath) {
    	var segs = filepath.split(path.sep);
		var fileRoot = getfileRoot(segs[1]);
		var realPath = path.join("/", fileRoot, segs[2]);
		return realPath;
    }
550326
function privCalculateStoredFilename(&$p_filedescr, &$p_options)
  {
    $v_result=1;
    
    // ----- Working variables
    $p_filename = $p_filedescr['filename'];
    if (isset($p_options[PCLZIP_OPT_ADD_PATH])) {
      $p_add_dir = $p_options[PCLZIP_OPT_ADD_PATH];
    }
    else {
      $p_add_dir = '';
    }
    if (isset($p_options[PCLZIP_OPT_REMOVE_PATH])) {
      $p_remove_dir = $p_options[PCLZIP_OPT_REMOVE_PATH];
    }
    else {
      $p_remove_dir = '';
    }
    if (isset($p_options[PCLZIP_OPT_REMOVE_ALL_PATH])) {
      $p_remove_all_dir = $p_options[PCLZIP_OPT_REMOVE_ALL_PATH];
    }
    else {
      $p_remove_all_dir = 0;
    }


    // ----- Look for full name change
    if (isset($p_filedescr['new_full_name'])) {
      // ----- Remove drive letter if any
      $v_stored_filename = PclZipUtilTranslateWinPath($p_filedescr['new_full_name']);
    }
    
    // ----- Look for path and/or short name change
    else {

      // ----- Look for short name change
      // Its when we cahnge just the filename but not the path
      if (isset($p_filedescr['new_short_name'])) {
        $v_path_info = pathinfo($p_filename);
        $v_dir = '';
        if ($v_path_info['dirname'] != '') {
          $v_dir = $v_path_info['dirname'].'/';
        }
        $v_stored_filename = $v_dir.$p_filedescr['new_short_name'];
      }
      else {
        // ----- Calculate the stored filename
        $v_stored_filename = $p_filename;
      }

      // ----- Look for all path to remove
      if ($p_remove_all_dir) {
        $v_stored_filename = basename($p_filename);
      }
      // ----- Look for partial path remove
      else if ($p_remove_dir != "") {
        if (substr($p_remove_dir, -1) != '/')
          $p_remove_dir .= "/";

        if (   (substr($p_filename, 0, 2) == "./")
            || (substr($p_remove_dir, 0, 2) == "./")) {
            
          if (   (substr($p_filename, 0, 2) == "./")
              && (substr($p_remove_dir, 0, 2) != "./")) {
            $p_remove_dir = "./".$p_remove_dir;
          }
          if (   (substr($p_filename, 0, 2) != "./")
              && (substr($p_remove_dir, 0, 2) == "./")) {
            $p_remove_dir = substr($p_remove_dir, 2);
          }
        }

        $v_compare = PclZipUtilPathInclusion($p_remove_dir,
                                             $v_stored_filename);
        if ($v_compare > 0) {
          if ($v_compare == 2) {
            $v_stored_filename = "";
          }
          else {
            $v_stored_filename = substr($v_stored_filename,
                                        strlen($p_remove_dir));
          }
        }
      }
      
      // ----- Remove drive letter if any
      $v_stored_filename = PclZipUtilTranslateWinPath($v_stored_filename);
      
      // ----- Look for path to add
      if ($p_add_dir != "") {
        if (substr($p_add_dir, -1) == "/")
          $v_stored_filename = $p_add_dir.$v_stored_filename;
        else
          $v_stored_filename = $p_add_dir."/".$v_stored_filename;
      }
    }

    // ----- Filename (reduce the path of stored name)
    $v_stored_filename = PclZipUtilPathReduction($v_stored_filename);
    $p_filedescr['stored_filename'] = $v_stored_filename;
    
    // ----- Return
    return $v_result;
  }
958579
function generateMakefile(testFiles, targetPath, callback) {
  var template = new templates.Template('Makefile.magic');
  var fullPath = path.join(targetPath, 'Makefile');
  var context = {
    test_files: testFiles.join(' \\\n ')
  };

  if (path.existsSync(fullPath)) {
    callback(new Error(sprintf('File "%s" already exists', fullPath)));
    return;
  }

  async.waterfall([
    template.load.bind(template),

    function render(template, callback) {
      template.render(context, callback);
    },

    function save(output, callback) {
      fs.writeFile(fullPath, output.join(''), callback);
    }
  ], callback);
}
889721
def remote_file_content_same_as?(full_path, content)
      Digest::MD5.hexdigest(content) == top.capture("md5sum #{full_path} | awk '{ print $1 }'").strip
    end
1255805
def not_ok(test, i)
      message = "not ok #{i + 1}"
      message += ' - ' + test.name if test.name
      message += "\n  " + test.errors.join("\n  ") if test.errors
      puts message
    end
784691
func rewriteFile(pattern, replace ast.Expr, p *ast.File) *ast.File {
	cmap := ast.NewCommentMap(fileSet, p, p.Comments)
	m := make(map[string]reflect.Value)
	pat := reflect.ValueOf(pattern)
	repl := reflect.ValueOf(replace)

	var rewriteVal func(val reflect.Value) reflect.Value
	rewriteVal = func(val reflect.Value) reflect.Value {
		// don't bother if val is invalid to start with
		if !val.IsValid() {
			return reflect.Value{}
		}
		for k := range m {
			delete(m, k)
		}
		val = apply(rewriteVal, val)
		if match(m, pat, val) {
			val = subst(m, repl, reflect.ValueOf(val.Interface().(ast.Node).Pos()))
		}
		return val
	}

	r := apply(rewriteVal, reflect.ValueOf(p)).Interface().(*ast.File)
	r.Comments = cmap.Filter(r).Comments() // recreate comments list
	return r
}
763642
func main() {
	if len(os.Args) < 2 {
		// Only have the command name. Need to print out help text.
		log.Printf("Usage: %v '$['json']['path']['string']' a.json...\n", os.Args[0])
		os.Exit(1)
	}
	filter, err := jsonpath.Parse(os.Args[1])
	if err != nil {
		log.Printf("Usage: %v '$['json']['path']['string']' a.json...\n", os.Args[0])
		log.Printf("Got the following error Parsing %v : %v\n", os.Args[1], err)
		os.Exit(1)
	}
	if len(os.Args) == 2 {
		// use stdinput
		data, err := ioutil.ReadAll(os.Stdin)
		if err != nil {
			log.Printf("Usage: %v '$['json']['path']['string']' a.json...\n", os.Args[0])
			log.Printf("Got the following error Reading from STDIN  %v\n", err)
			os.Exit(1)
		}
		d, err := applyFilter(filter, data)
		if err != nil {
			log.Printf("Usage: %v '$['json']['path']['string']' a.json...\n", os.Args[0])
			log.Printf("Got the following error Applying filter  %v\n", err)
			os.Exit(1)
		}
		data, err = json.MarshalIndent(d, "", "   ")
		if err != nil {
			log.Printf("Usage: %v '$['json']['path']['string']' a.json...\n", os.Args[0])
			log.Printf("Got the following error Printing out json %v\n", err)
			os.Exit(1)
		}
		fmt.Println(string(data))
	}
	for _, filename := range os.Args[2:] {
		data, err := ioutil.ReadFile(filename)
		if err != nil {
			log.Printf("Got the following error Reading from %v  %v\n", filename, err)
			continue
		}
		d, err := applyFilter(filter, data)
		if err != nil {
			log.Printf("Got the following error Applying filter for %v  %v\n", filename, err)
			continue
		}
		data, err = json.MarshalIndent(d, "", "   ")
		if err != nil {
			log.Printf("Got the following error Trying to print result for file %v  %v\n", filename, err)
			continue
		}
		fmt.Println(string(data))
	}

}
865121
function _findEach(src, match, quotes, comments, callback) {
        var from = 0;
        var to;
        while (from < src.length) {
            to = _find(src, match, from, quotes, comments);
            if (to < 0) {
                to = src.length;
            }
            callback(src.substr(from, to - from));
            from = to + 1;
        }
    }
488079
private void verifyLocalFilePath(String localFilePathFromGS)
  throws SnowflakeSQLException
  {
    if (command == null)
    {
      logger.error("null command");
      return;
    }

    if (command.indexOf(FILE_PROTOCOL) < 0)
    {
      logger.error(
          "file:// prefix not found in command: {}", command);
      return;
    }

    int localFilePathBeginIdx = command.indexOf(FILE_PROTOCOL) +
                                FILE_PROTOCOL.length();
    boolean isLocalFilePathQuoted =
        (localFilePathBeginIdx > FILE_PROTOCOL.length()) &&
        (command.charAt(localFilePathBeginIdx - 1 - FILE_PROTOCOL.length()) == '\'');

    // the ending index is exclusive
    int localFilePathEndIdx = 0;
    String localFilePath = "";

    if (isLocalFilePathQuoted)
    {
      // look for the matching quote
      localFilePathEndIdx = command.indexOf("'", localFilePathBeginIdx);
      if (localFilePathEndIdx > localFilePathBeginIdx)
      {
        localFilePath = command.substring(localFilePathBeginIdx,
                                          localFilePathEndIdx);
      }
      // unescape backslashes to match the file name from GS
      localFilePath = localFilePath.replaceAll("\\\\\\\\", "\\\\");
    }
    else
    {
      // look for the first space or new line or semi colon
      List<Integer> indexList = new ArrayList<>();
      char[] delimiterChars = {' ', '\n', ';'};
      for (int i = 0; i < delimiterChars.length; i++)
      {
        int charIndex = command.indexOf(delimiterChars[i], localFilePathBeginIdx);
        if (charIndex != -1)
        {
          indexList.add(charIndex);
        }
      }

      localFilePathEndIdx = indexList.isEmpty() ? -1 : Collections.min(indexList);

      if (localFilePathEndIdx > localFilePathBeginIdx)
      {
        localFilePath = command.substring(localFilePathBeginIdx,
                                          localFilePathEndIdx);
      }
      else if (localFilePathEndIdx == -1)
      {
        localFilePath = command.substring(localFilePathBeginIdx);
      }
    }

    if (!localFilePath.isEmpty() && !localFilePath.equals(localFilePathFromGS))
    {
      throw new SnowflakeSQLException(SqlState.INTERNAL_ERROR,
                                      ErrorCode.INTERNAL_ERROR.getMessageCode(),
                                      "Unexpected local file path from GS. From GS: " +
                                      localFilePathFromGS + ", expected: " + localFilePath);
    }
    else if (localFilePath.isEmpty())
    {
      logger.debug(
          "fail to parse local file path from command: {}", command);
    }
    else
    {
      logger.trace(
          "local file path from GS matches local parsing: {}", localFilePath);
    }
  }
1277466
def check_puppetfile_content
      puppetfile_content = File.read("#{project_root}/puppet/steps/#{step_name}/Puppetfile").strip
      `rm "#{project_root}/puppet/steps/#{step_name}/Puppetfile"` if puppetfile_content.scan(/^\s*(mod\s*.+?)$/).flatten.empty?
    end
92520
private void verifyFile(String[] args, int startIndex) {
    Path root = null;
    if (args.length <= startIndex) {
      throw new IllegalArgumentException("too few arguments");
    }
    String arg = args[startIndex];
    root = new Path(arg);
    try {
      FileSystem fs = root.getFileSystem(conf);
      // Make sure default uri is the same as root  
      conf.set(FileSystem.FS_DEFAULT_NAME_KEY, fs.getUri().toString());
      FileVerifier fv = new FileVerifier(conf);
      fv.verifyFile(root, System.out);
    } catch (IOException ex) {
      System.err.println("verifyFile: " + ex);
    }
  }
763571
function findFirstFileMatchingAfterNext($ns, $name, $filename) {
		$nextPtr = \strrpos($ns, '\\next\\');

		// due to the way the syntax works, the namespace before the keyword
		// next is implied from the file namespace so it's always a complete
		// namespace rather then a partial one
		$skipNamespace = substr($ns, 0, $nextPtr + 1);

		$targetNs = substr($ns, $nextPtr + 6); // strlen('\\next\\') = 6

		$skipped = false;
		foreach ($this->state['modules'] as $module) {

			if ( ! $skipped) {
				if ($module['namespace'] == $skipNamespace) {
					$skipped = true;
				}

				continue;
			}

			if ( ! $module['enabled']) {
				continue;
			}

			if (\strripos($module['namespace'], $targetNs) !== false) {
				$targetfile = $module['path'].'/src/'.$filename.'.php';
				if ($this->file_exists($targetfile)) {
					$target = $module['namespace'].$name;
					return [ $targetfile, $module['namespace'], $target ];
				}
			}
		}

		return null; // failed to match anything
	}
619894
function expandScriptRequirePath(content, file) {
    var requireRegStr = '(\\brequire(?:\\s*\\.\\s*(?:async|defer))?\\s*\\(\\s*)(' +
      stringRegStr + '|' +
      jsStringArrayRegStr + ')';

    //first match the string or comment
    var reg = new RegExp(stringRegStr + '|' +
    jscommentRegStr + '|' +
    requireRegStr, 'g');

    content = tagFilter.filterBlock(content,
      'script', smarty_left_delimiter, smarty_right_delimiter,
      function (outter, attr, inner) {

        inner = inner.replace(reg,
          function (all, requirePrefix, requireValueStr) {
            var hasBrackets = false;

            if (requirePrefix) {

              //if here has '[]' , cut it
              requireValueStr = requireValueStr.trim().replace(/(^\[|\]$)/g, function (m, v) {
                if (v) {
                  hasBrackets = true;
                }
                return '';
              });
              var info;
              var path;
              var ret;
              if (hasBrackets) { //Array
                var requireValue = requireValueStr.split(/\s*,\s*/);
                all = requirePrefix +
                '[' + requireValue.map(function (value) {
                  info = her.util.stringQuote(value);
                  path = info.rest;
                  ret = info.quote + her.uri.getId(path, file.dirname).id + info.quote;
                  return ret;
                }).join(',') + ']';
              } else { //String
                info = her.util.stringQuote(requireValueStr);
                path = info.rest;

                ret = info.quote + her.uri.getId(path, file.dirname).id + info.quote;
                all = requirePrefix + ret;
              }

            }
            return all;
          });

        return smarty_left_delimiter +
          'script' +
          attr +
          smarty_right_delimiter +
          inner +
          smarty_left_delimiter +
          '/script' +
          smarty_right_delimiter;
      });
    return content;
  }
904118
def define
      lib_path = @libs.join(File::PATH_SEPARATOR)
      actual_name = Hash === name ? name.keys.first : name
      unless Rake.application.last_comment
        desc "Analyze code coverage with tests" + 
          (@name==:rcov ? "" : " for #{actual_name}")
      end
      task @name do
        run_code = ''
        RakeFileUtils.verbose(@verbose) do
          run_code =
          case rcov_path
          when nil, ''
            "-S rcov"
          else %!"#{rcov_path}"!
          end
          ruby_opts = @ruby_opts.clone
          ruby_opts.push( "-I#{lib_path}" )
          ruby_opts.push run_code
          ruby_opts.push( "-w" ) if @warning
          ruby ruby_opts.join(" ") + " " + option_list +
          %[ -o "#{@output_dir}" ] +
          file_list.collect { |fn| %["#{fn}"] }.join(' ')
        end
      end

      desc "Remove rcov products for #{actual_name}"
      task paste("clobber_", actual_name) do
        rm_r @output_dir rescue nil
      end

      clobber_task = paste("clobber_", actual_name)
      task :clobber => [clobber_task]

      task actual_name => clobber_task
      self
    end
1084295
function(file) {
    var html   = filter.get('tag', fss.filetype(file))('test');
    var prefix = config.root ? config.root : '';
    var suffix = config.timestamp && html ? '?v=' + config.time : '';
    var encode = fss.relative(file).replace(/\s/g, '%20');
    return path.join(prefix, encode) + suffix;
}
498297
func main() {
	if len(os.Args) < 4 {
		fmt.Println("Usage: winuserdata <copyrightyear> <gofile> <pkgname>")
	}

	addJujuUser, err := compoundJujuUser()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
	winpowershell, err := compoundWinPowershellFuncs()
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	var buf bytes.Buffer
	type content struct {
		AddJujuUser             string
		WindowsPowershellHelper string
		CopyrightYear           string
		Pkgname                 string
	}

	t, err := template.New("").Parse(fileTemplate)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}

	addJujuUser = fmt.Sprintf("\n%s", addJujuUser)
	winpowershell = fmt.Sprintf("\n%s", winpowershell)

	// Quote any ` in the data.
	addJujuUser = strings.Replace(addJujuUser, "`", "` + \"`\" + `", -1)
	winpowershell = strings.Replace(winpowershell, "`", "` + \"`\" + `", -1)

	t.Execute(&buf, content{
		AddJujuUser:             fmt.Sprintf("`%s`", addJujuUser),
		WindowsPowershellHelper: fmt.Sprintf("`%s`", winpowershell),
		Pkgname:                 os.Args[3],
		CopyrightYear:           os.Args[1],
	})

	err = ioutil.WriteFile(os.Args[2], buf.Bytes(), 0644)
	if err != nil {
		fmt.Println(err)
		os.Exit(1)
	}
}
733828
func FlushCoverage() {
	// We're not actually going to run any tests, but we need Go to think we did so it writes
	// coverage information to disk. To achieve this, we create a bunch of empty test suites and
	// have it "run" them.
	tests := []testing.InternalTest{}
	benchmarks := []testing.InternalBenchmark{}
	examples := []testing.InternalExample{}

	var deps fakeTestDeps

	dummyRun := testing.MainStart(deps, tests, benchmarks, examples)
	dummyRun.Run()

	// Once it writes to the temporary path, we move it to the intended path.
	// This gets us atomic updates from the perspective of another process trying to access
	// the file.
	if err := os.Rename(tempCoveragePath(), coverageFile); err != nil {
		klog.Errorf("Couldn't move coverage file from %s to %s", coverageFile, tempCoveragePath())
	}
}