現在使用している出力中ファイルをクローズし、一時ファイルサフィックスが無いファイル名称にリネームする。
195236
private void closeRenameTmp2BaseFile()
    {
        try
        {
            this.currentWriter.close();
        }
        catch (IOException ex)
        {
            String logFormat = "Failed to HDFS file close. Continue file switch. : TargetUri={0}";
            String logMessage = MessageFormat.format(logFormat, this.currentOutputUri
                    + this.currentSuffix);
            logger.warn(logMessage, ex);
        }

        boolean isFileExists = true;

        try
        {
            isFileExists = this.fileSystem.exists(new Path(this.currentOutputUri));
        }
        catch (IOException ioex)
        {
            String logFormat = "Failed to search target file exists. Skip file rename. : TargetUri={0}";
            String logMessage = MessageFormat.format(logFormat, this.currentOutputUri);
            logger.warn(logMessage, ioex);
            return;
        }

        if (isFileExists)
        {
            String logFormat = "File exists renamed target. Skip file rename. : BeforeUri={0} , AfterUri={1}";
            String logMessage = MessageFormat.format(logFormat, this.currentOutputUri
                    + this.currentSuffix, this.currentOutputUri);
            logger.warn(logMessage);
        }
        else
        {
            try
            {
                this.fileSystem.rename(new Path(this.currentOutputUri + this.currentSuffix),
                        new Path(this.currentOutputUri));
            }
            catch (IOException ex)
            {
                String logFormat = "Failed to HDFS file rename. Skip rename file. : BeforeUri={0} , AfterUri={1}";
                String logMessage = MessageFormat.format(logFormat, this.currentOutputUri
                        + this.currentSuffix, this.currentOutputUri);
                logger.warn(logMessage, ex);
            }
        }

    }
289025
function task () {
  run = true;
  var item = messages.shift();
  if (!item) {
    run = false;

  // 書き込み
  } else if ('message' in item) {
    if (output_) {
      write(item);
    } else {
      task();
    }

  // パスの変更
  } else if (item.path) {
    p_ = path.resolve(p_, item.path);
    task();

  // 出力のコントロール
  } else if ('output' in item) {
    output_ = item.output;
    task();

  } else {
    task();
  }
}
956161
private static void statFile(String fname) {
    try {
      Path path = Paths.get(new URI(fname));
      long size = Files.size(path);
      System.out.println(fname + ": " + size + " bytes.");
    } catch (Exception ex) {
      System.out.println(fname + ": " + ex.toString());
    }
  }
73934
def writesgf(self, sgffilename):
        ""

        size = self.size
        outfile = open(sgffilename, "w")
        if not outfile:
            print "Couldn't create " + sgffilename
            return
        black_name = self.blackplayer.get_program_name()
        white_name = self.whiteplayer.get_program_name()
        black_seed = self.blackplayer.get_random_seed()
        white_seed = self.whiteplayer.get_random_seed()
        handicap = self.handicap
        komi     = self.komi
        result   = self.resultw

        outfile.write("(;GM[1]FF[4]RU[Japanese]SZ[%s]HA[%s]KM[%s]RE[%s]\n" %
                      (size, handicap, komi, result))
        outfile.write("PW[%s (random seed %s)]PB[%s (random seed %s)]\n" %
                      (white_name, white_seed, black_name, black_seed))
        outfile.write(self.sgffilestart)

        if handicap > 1:
            outfile.write("AB");
            for stone in self.handicap_stones:
                outfile.write("[%s]" %(coords_to_sgf(size, stone)))
            outfile.write("PL[W]\n")

        to_play = self.first_to_play

        for move in self.moves:
            sgfmove = coords_to_sgf(size, move)
            outfile.write(";%s[%s]\n" % (to_play, sgfmove))
            if to_play == "B":
                to_play = "W"
            else:
                to_play = "B"
        outfile.write(")\n")
        outfile.close
1104632
function dropFile() {
        // Check for File API support
        // if (typeof window.File === 'undefined' ||
        //     typeof window.FileReader === 'undefined') {
        //   alert('The File APIs are not fully supported in this browser.');
        // }

        $("#preview").bind('dragover', function () {
            $("#paper").addClass('hover');
            return false;
        }).bind("dragend", function () {
            $("#paper").removeClass('hover');
            return false;
        }).bind("drop", function (e) {
            $("#paper").removeClass('hover');
            e.stopPropagation();
            e.preventDefault();

            renderImportedFile(e.originalEvent.dataTransfer.files[0]);
            return false;
        });
    }
490266
function _writeFile(i_sFilename, i_oFile, i_oCallback) {
    var l_sFilename = i_sFilename,
        l_oBuffer = new Buffer(i_oFile.fileData); // filedata is Uint8Array
    fs.writeFile(l_sFilename, l_oBuffer, function(err) {
        if (err) {
            console.log("Error writting file ", err);
            l_sFilename = null;
        }
        i_oCallback(l_sFilename);
    });
}
1139536
function ( err ) {
    // 报错文件名
    var fileName = err.fileName;
    // 报错类型
    var name = err.name;
    // 报错信息
    var message = err.message;
    // 出错代码位置
    var loc = err.loc;

    var logInfo = '报错文件：' + fileName + '报错类型：' + name + '出错代码位置：' + loc.line + ',' + loc.column;

    util.log( logInfo );

    this.end();
}
662435
function dumpFiles(title, fn) {
            var matches = fn();
            if (matches.length) {
                log.info("");
                log.info((title + ":")['green']);
                for (var i = 0; i < matches.length; i++) {
                    if (matches[i].src === matches[i].dst) {
                        log.info(matches[i].dst);
                    } else {
                        log.info(matches[i].dst + ' (from ' + matches[i].src + ')');
                    }
                }
            }
        }
244167
def verbosedump(value, fn, compress=None):
    """"""
    print('Saving "%s"... (%s)' % (fn, type(value)))
    dump(value, fn, compress=compress)
388670
public static function ReflectFromIniFile ($ini_file_path, $extension = null, $options = []) {
		$cache_dir		= isset($options['cache']) ? $options['cache'] : null;

		if ($cache_dir) {
			$ini = ArrayCache::GetCache($ini_file_path, $cache_dir, $options);
			if ($ini) {
				static::Set($ini);
				return $ini;
			}
		}

		//ファイル生存系確認：本当はvalidationでやりたい
		FileSystem::IsReadableFile($ini_file_path);

		$allow_parameter_list = array_keys((($extension === null) ? static::GetCurrent() : static::GetCurrent($extension)));
		switch ($extension) {
			case static::SESSION:
				$allow_parameter_list[] = static::URL_REWRITER_TAGS;
				break;
		}

		$ini = IniFile::GetConfig($ini_file_path, $allow_parameter_list, $options);
		if ($cache_dir) {
			ArrayCache::SetCache($ini_file_path, $cache_dir, $ini, $options);
		}

		return static::Set($ini);
	}
45963
def sfload(self, filename, update_midi_preset=0):
        """"""
        return fluid_synth_sfload(self.synth, filename.encode(), update_midi_preset)
1266777
function searchInFile(row, callback){
		// console.log(row);

		var result = {
			'matched': false,
			'type': row.type,
			'count': 0
		};

		if( _this.cond.matchFileName ){
			if( php.basename(row.path).match( _this.cond.keyword ) ){
				// ファイル名にキーワードマッチング
				result.matched = true;
			}
		}

		if( row.type == 'file' ){
			// ファイルの場合
			fs.readFile( row.path, function( err, bin ){
				if(_this.completed){
					return;
				}

				var result = {
					'matched': false,
					'type': 'file',
					'count': 0
				};
				if(err){
					// エラー
					countDone ++;
					result.error = err;
					_this.cond.error(row.path, result);
					_this.cond.progress(countDone, countTarget);
					callback();
					return;
				}
				bin = bin.toString('UTF8');

				var matched = bin.match( _this.cond.keyword );
				if( matched ){
					// キーワードマッチング
					result.matched = true;
					result.count = matched.length;
				}

				countDone ++;
				if( result.matched ){
					// マッチした場合
					_this.cond.match(row.path, result);
				}else{
					// マッチしなかった場合
					_this.cond.unmatch(row.path, result);
				}
				_this.cond.progress(countDone, countTarget);
				callback();
				return;

			} );
		}else{
			// ディレクトリの場合
			countDone ++;
			if( result.matched ){
				// マッチした場合
				_this.cond.match(row.path, result);
			}else{
				// マッチしなかった場合
				_this.cond.unmatch(row.path, result);
			}
			_this.cond.progress(countDone, countTarget);
			callback();
			return;
		}
	}
906610
public void SFFS() throws Exception {
		int NumTemplate = Templates.length;
		CurSet = new boolean[NumTemplate];
		LeftSet = new boolean[NumTemplate];
		for (int i = 0; i < NumTemplate; i++) {
			CurSet[i] = false;
			LeftSet[i] = true;
		}
		Evaluate(Templates, CurSet);
		boolean continueDelete = false;
		while (SetSize(CurSet) <= NumTemplate) {
			if (!continueDelete) {
				Integer theInt = BooleanSet2Integer(CurSet);
				int best = BestFeatureByAdding(CurSet, LeftSet);
				if (best != -1) {
					System.out.println("Add Best " + best);
					AlreadyAdded.add(theInt);
					CurSet[best] = true;
					LeftSet[best] = false;
					printAccuracy(CurSet);
				}
			}
			Integer theInt = BooleanSet2Integer(CurSet);
			// 被删除过的集合就不再删除了
			if (AlreadyRemoved.contains(theInt)) {
				continueDelete = false;
				continue;
			} else {
				int worst = WorstFeatureByRemoving(CurSet);
				boolean[] TestSet = CurSet.clone();
				TestSet[worst] = false;
				double accuracy = Evaluate(Templates, TestSet);
				if (accuracy >= AccuracyRecords.get(theInt)) {
					System.out.println("Remove Worst " + worst);
					AlreadyRemoved.add(theInt);
					CurSet[worst] = false;
					LeftSet[worst] = true;
					printAccuracy(CurSet);
					if (SetSize(CurSet) == 0) {
						continueDelete = false;
					} else
						continueDelete = true;
				} else {
					continueDelete = false;
					continue;
				}
			}
		}
		printAccuracyRecords(AccuracyRecords);
		ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(
				"/home/zliu/corpus/testTemplate/SFFS.ser"));
		oos.writeObject(AccuracyRecords);
		oos.close();

	}
228319
function makeFiles(list, dest, savedir, callback) {
  let shell = path.join(__dirname, '../sh/copy.sh');

  return exec('chmod +x ' + shell, (err) => {
    if (err !== null) throw ('[Error: makeFiles: chmod:] ' + err);
    let tmp = []; // 保存先のパスを格納する配列
    let fin = countup(list.length);

    list.forEach((file, index) => {
      let source = file; // コピー元
      let target = path.join(savedir, dest, file); // 保存先
      tmp[index] = target;

      // ファイルをコピーする
      let copied = execFile(shell, [source, target, index], (error, stdout, stderr) => {
        if (error !== null) throw ('[Error: makeFiles: copy.sh:] ' + error);
        fin.step(+stdout, (closed, progress) => {
          return (closed && callback) && callback(tmp, path.join(savedir, dest));
        });
      });
    });
  });
}
722345
function onlyCreateFrom(summaryFilePath){
    /**
     * @var {string} agm 额外需要写入文件的内容。
     */
    var agm = arguments[1];
    var ostpye = require('os').type;
    if(fs.existsSync(summaryFilePath)){
        var rl = readline.createInterface({
            input: fs.createReadStream(summaryFilePath)
        });
        rl.on('line', function (line) {
            var title = line.match(/\[[\s\S]*\]\B/g);
            title = '# ' + title[0].replace(/^\[|\]$/g, "");
            var filePath = line.match(/\]\([\w\W]*\)\B/g);
            var fileName = filePath[0].replace(/[\]\(\)]/g,"");
            if(ostpye=="Windows_NT" && agm!==undefined){
                var wData = title + '\r\n'+agm;
                nNmc.fs_wfSync(fileName,wData,false)
            }else if(ostpye !=="Windows_NT" && agm!==undefined){
                var wData = title + '\n'+agm;
                nNmc.fs_wfSync(fileName,wData,false)
            }else{
                nNmc.fs_wfSync(fileName,title,false)
            }
            console.log(`${chalk.yellow('summarybuilder:  ')}`+fileName+'.........created!');
        });
    }else{
        console.log(`${chalk.yellow('summarybuilder:  ')}找不到文件(No such file)--`+summaryFilePath)
    }
}
258342
function(){
		var lines = this.fstr.split("\n");
		var firstline = lines.shift();
		delete this.fstr;
		
		/* ヘッダからパズルの種類・ファイルの種類を判定する */
		if(firstline.match(/^pzprv3/)){
			this.type = FILE_PZPR;
			if(firstline.match(/pzprv3\.(\d+)/)){ this.filever = +RegExp.$1;}
			this.pid = lines.shift();
			this.qdata = lines.join("\n");
		}
		else if(firstline.match(/^\<\?xml/)){ // jshint ignore:line
			this.type = FILE_PBOX_XML;
			lines.unshift(firstline);
			this.qdata = lines.join("\n");
			if(!!DOMParser){
				this.body = (new DOMParser()).parseFromString(this.qdata, 'text/xml');
				this.pid = this.body.querySelector('puzzle').getAttribute('type');
			}
			else{ this.pid = '';}
		}
		else if(firstline.match(/^\d+$/)){
			this.type = FILE_PBOX;
			lines.unshift(firstline);
			this.qdata = lines.join("\n");
		}
		else{
			this.pid = '';
		}
		this.pid = pzpr.variety.toPID(this.pid);
		
		return (!!this.pid);
	}
1159039
function(wav_input_file_obj, requested_input_filename, db_done) {

    var header_chunk_size = 44;
    var property_input_buffer = "header_buffer";

    fs.open(requested_input_filename, 'r', function(error, fd) {

        if (error) {
            db_done("ERROR - failed to open file " + requested_input_filename +
                " message : " + error.message, wav_input_file_obj);
        } else {

            wav_input_file_obj[property_input_buffer] = new Buffer(header_chunk_size);

            fs.read(fd, wav_input_file_obj[property_input_buffer], 0, header_chunk_size, 0, function(err, end_index) {

                // console.log("wav_input_file_obj[property_input_buffer] ", 
                //             wav_input_file_obj[property_input_buffer].toString('utf-8', 0, end_index));

                // console.log("wav_input_file_obj[property_input_buffer] ", wav_input_file_obj[property_input_buffer]);

                // console.log("end_index ", end_index);

                inner_parse_header(wav_input_file_obj, property_input_buffer, db_done);
            });            
        }
    });
}