Whenever a file is closed call this function.
The function will send the analytics Data.
We only log the standard filetypes and fileSize
@param {String} filePath The path of the file to be registered
420712
function fileClosed(file) {
        if (!file) {
            return;
        }
        var language = LanguageManager.getLanguageForPath(file._path),
            size = -1;

        function _sendData(fileSize) {
            var subType = "";

            if(fileSize/1024 <= 1) {

                if(fileSize < 0) {
                    subType = "";
                }
                if(fileSize <= 10) {
                    subType = "Size_0_10KB";
                } else if (fileSize <= 50) {
                    subType = "Size_10_50KB";
                } else if (fileSize <= 100) {
                    subType = "Size_50_100KB";
                } else if (fileSize <= 500) {
                    subType = "Size_100_500KB";
                } else {
                    subType = "Size_500KB_1MB";
                }

            } else {
                fileSize = fileSize/1024;
                if(fileSize <= 2) {
                    subType = "Size_1_2MB";
                } else if(fileSize <= 5) {
                    subType = "Size_2_5MB";
                } else {
                    subType = "Size_Above_5MB";
                }
            }

            sendAnalyticsData(commonStrings.USAGE + commonStrings.FILE_CLOSE + language._name + subType,
                                commonStrings.USAGE,
                                commonStrings.FILE_CLOSE,
                                language._name.toLowerCase(),
                                subType
                             );
        }

        file.stat(function(err, fileStat) {
            if(!err) {
                size = fileStat.size.valueOf()/1024;
            }
            _sendData(size);
        });
    }
1129419
function registerPartial(filepath, callback) {
    fs.readFile(filepath, 'utf8', function (err, data) {
      if (err) callback(err);
      hbs.registerPartial(path.parse(filepath).name, data);
      callback(null);
    });
  }
1163265
public void logCloseFile(String path, INodeFile newNode) {
    CloseOp op = CloseOp.getInstance();
    op.set(newNode.getId(),
        path, 
        newNode.getReplication(), 
        newNode.getModificationTime(),
        newNode.getAccessTime(),
        newNode.getPreferredBlockSize(),
        newNode.getBlocks(),
        newNode.getPermissionStatus(),
        null,
        null);
    logEdit(op);
  }
974779
function handle(filePath) {
    var file = toVFile(filePath)
    var result = test(file)

    if (mask(result, INCLUDE)) {
      if (one) {
        callback(null, file)
        return true
      }

      results.push(file)
    }

    if (mask(result, BREAK)) {
      callback(null, one ? null : results)
      return true
    }
  }
24418
function (filepath, options, callback) {
        if (typeof options === 'function') {
            callback = options;
            options = undefined;
        }

        options = options || '';
        var args = _.compact([filepath].concat(options.replace(/\ \ /g, ' ').split(' ')));

        logger.debug('cmd:', constant.PROG_OPTIPNG, args.join(' '));

        var proc = spawn(constant.PROG_OPTIPNG, args);

        proc.stdout.on('data', function (data) {
            logger.debug(data.toString());
        });

        proc.stderr.on('data', function (data) {
            logger.debug(data.toString());
        });

        proc.addListener('exit', function (e) {
            if (e) {
                return callback(e);
            }
            callback();
        });
    }
985618
function(filepath) {
                        // Construct the destination file path.
                        var dest = path.join(
                            grunt.config('copy.coverage.dest'),
                            path.relative(process.cwd(), filepath)
                        );
                        // Return false if the file exists.
                        return !(grunt.file.exists(dest));
                    }
254469
function processJavaScriptFilePath(filePath: string, fileByteSize: number) {
      // If `all` was configured then we don't need to check for the Flow
      // header pragma.
      if (options.all) {
        filePaths.push(filePath);
        return;
      }
      // If we were rejected then we should not continue.
      if (rejected === true) {
        return;
      }
      // We are now waiting on this asynchronous task.
      waiting++;
      // Open the file path.
      fs.open(filePath, 'r', (error, file) => {
        if (error) {
          return reject(error);
        }
        // Get the smaller of our pragma chars constant and the file byte size.
        const bytes = Math.min(PRAGMA_BYTES, fileByteSize);
        // Create the buffer we will read to.
        const buffer = new Buffer(bytes);
        // Read a set number of bytes from the file.
        fs.read(file, buffer, 0, bytes, 0, error => {
          if (error) {
            return reject(error);
          }
          // If the buffer has the @flow pragma then add the file path to our
          // final file paths array.
          if (buffer.includes('@flow')) {
            filePaths.push(filePath);
          }
          // Close the file.
          fs.close(file, error => {
            if (error) {
              return reject(error);
            }
            // We are done with this async task
            done();
          });
        });
      });
    }
1169787
function processFile(filePath, callback) {
  /*jshint validthis:true */
  var processor = this;
  processor.emit('processing.start', {
    file: filePath
  });

  encoder.detectBom(filePath, function(err, bomName) {
    var status = 'good';

    if (err) {
      status = 'error';
      processor.emit('processing.error', {
        file: filePath,
        message: 'Skipping file with errors during encoding detection: ' + err
      });
      return callback(null, status);
    }
    else {
      var needsFixing = false;
      var lastByteSequenceWasCR = false;
      var bytesPerBom = encoder.getBytesPerBom(bomName);
      var bytesPerControlChar = encoder.getBytesPerControlChar(bomName);

      var transformBuffer = [];
      var tempBuffer = null;

      // Fast-forward past the BOM if present
      var onFirstReadable = function() {
        var bomBuffer = this.read(bytesPerBom);
        if (bomBuffer == null || bomBuffer.length !== bytesPerBom) {
          status = 'error';
          processor.emit('processing.error', {
            file: filePath,
            message: 'Skipping file with errors during read: Unable to read past the expected BOM'
          });
          return callback(null, status);
        }
      };
      var onReadable = function() {
        var data = this.read(),
            i = 0,
            len = data.length,
            cursor = i,
            buffer;
        for ( ; i < len; i += bytesPerControlChar) {
          buffer = slicer.call(data, i, i + bytesPerControlChar);

          // If we read less bytes than the minimum number necessary to register
          // as a complete character in this encoding, put them back on the front
          // of the read queue for the next read and then bail out.
          if (buffer.length < bytesPerControlChar) {
            if (!tempBuffer || !arraysMatch(buffer, tempBuffer)) {
              tempBuffer = buffer;
              // Save these rogue bytes to inspect on the next time around
              this.unshift(data.slice(i, i + buffer.length));
              // Break out of the loop
              break;
            }
            else {
              // This will prevent an infinite loop if the number of bytes in the file
              // is erroneous/irregular, e.g. a total of 7 bytes in a UTF-16 file.
              status = 'error';

              // Send a signal to cause early termination (i.e. trigger the 'end' event)
              this.push(null);
              // Break out of the loop
              break;
            }
          }
          tempBuffer = null;

          if (encoder.doesByteSequenceSuggestBinary(buffer, bomName)) {
            status = 'skip';
            processor.emit('processing.skip', {
              file: filePath,
              message: 'Skipping suspected binary file'
            });
            // Send a signal to cause early termination (i.e. trigger the 'end' event)
            this.push(null);
            // Break out of the loop
            break;
          }
          else {
            if (encoder.isByteSequenceCR(buffer, bomName)) {
              lastByteSequenceWasCR = true;
            }
            else {
              if (lastByteSequenceWasCR && encoder.isByteSequenceLF(buffer, bomName)) {
                needsFixing = true;

                // Push everything (except for CRs) into the outgoing buffer
                transformBuffer.splice.apply(transformBuffer, [transformBuffer.length, 0].concat(slicer.call(data, cursor, i - bytesPerControlChar)));
                cursor = i;
              }

              // If this is the last byte of the buffer, push the remaining data into the outgoing buffer
              if (i + bytesPerControlChar === len && needsFixing) {
                // Push everything (except for CRs) into the outgoing buffer
                transformBuffer.splice.apply(transformBuffer, [transformBuffer.length, 0].concat(slicer.call(data, cursor)));
              }

              // Reset
              lastByteSequenceWasCR = false;
            }
          }
        }
      };
      var onError = function(err) {
        status = 'error';
        processor.emit('processing.error', {
          file: filePath,
          message: 'Skipping file with errors during read: ' + err
        });
        return callback(null, status);
      };
      var onEnd = function() {
        if (status === 'good') {
          if (needsFixing) {
            status = 'bad';
            this.on('close', function() {
              // Overwrite the existing file with the fixed data
              process.nextTick(function() {
                processor.emit('convert.start', {
                  file: filePath
                });

                //
                // TODO: Is there a more optimal way to do this?
                //       e.g. TransformStream, write to temp then move, etc.
                //
                fs.writeFile(filePath, new Buffer(transformBuffer), function(err) {
                  if (err) {
                    status = 'error';
                    processor.emit('convert.error', {
                      file: filePath,
                      message: 'Unexpected error during conversion process: ' + err
                    });
                  }
                  else {
                    status = 'fix';
                    processor.emit('convert.end', {
                      file: filePath
                    });
                  }

                  processor.emit('processing.end', {
                    file: filePath
                  });
                  return callback(null, status);
                });
              });
            });
          }
          else {
            status = 'skip';
            processor.emit('processing.skip', {
              file: filePath,
              message: 'Skipping file with all correct line endings'
            });
          }
        }

        if (status === 'skip') {
          processor.emit('processing.end', {
            file: filePath
          });
        }
        if (status !== 'bad') {
          return callback(null, status);
        }
      };

      var reader = new Readable();
      reader.wrap(fs.createReadStream(filePath));

      if (bytesPerBom > 0) {
        reader.once('readable', onFirstReadable);
      }
      reader
        .on('readable', onReadable)
        .on('error', onError)
        .on('end', onEnd);
    }
  });
}
1117857
function logfile(val) {
  var fd;
  // empty string disables use of log file
  if(val) {
    try {
      fd = fs.openSync(val, 'a');
      fs.closeSync(fd);
    }catch(e) {
      throw new Error(util.format('Can\'t open the log file: %s', val));
    }
  }
}
1298301
public static void closeFileStream(InputStream inputStream, String filePath){
        try {
            if (inputStream != null) {
                inputStream.close();
            }
        } catch (IOException e) {
            LOG.error("close file {} occur an IOExcpetion {}", filePath, e);
        }
    }
1134373
function(filePath, targetPath, callback) {
            client
                .moveFile(filePath, targetPath)
                .then(function() {
                    __executeCallbackAsync(callback, [null]);
                })
                .catch(callback);
        }
1252009
function registerTemplate(filepath, callback) {
    fs.readFile(filepath, 'utf8', function (err, data) {
      if (err) callback(err);
      callback(null, {
        name: path.parse(filepath).name,
        template: hbs.compile(data)
      });
    });
  }
225652
function(filePath) {

    if( path.extname(filePath) === '.js' ) {
      filePath = path.dirname(filePath);
    }

    ////console.log(colors.gray('loading meta:'), filePath);

    this.filePath = filePath;

    var meta = require(filePath + '/meta');

    //set the name of the class to the last name value
    this.name = meta.name;

    if( typeof this.meta === 'object' ) {
      this.meta = merge(meta, this.meta);
    } else {
      this.meta = meta;
    }
  }
1205473
function realRequirPath(filePath) {
  // console.log('realRequirPath:filePath: ' + filePath);
  var jsFilePath = filePath + '.js';
  if (fs.existsSync(filePath)) {
    if (fs.statSync(filePath).isDirectory()) {
      jsFilePath = filePath + '.js';
      if (fs.existsSync(jsFilePath)) {
        return jsFilePath;
      } else {
        jsFilePath = path.join(filePath, 'index.js');
      }
      // console.log('realRequirPath:jsFilePath: ' + jsFilePath);
    } else if (fs.statSync(filePath).isFile()) {
      return filePath;
    } else {
      return null;
    }
  } else {
    jsFilePath = filePath + '.js';
    // console.log('realRequirPath:filePath: ' + filePath);
  }

  if (fs.existsSync(jsFilePath)) {
    // console.log('realRequirPath:filePath: ' + filePath);
    return jsFilePath;
  } else {
    return null;
  }
}
1024809
function writeFile(filepath, data, options, callback) {
  if (typeof options === 'function') {
    callback = options;
    options = {};
  }

  if (!Buffer.isBuffer(data)) {
    return callback(new TypeError('Data must be a Buffer'));
  }

  if (!options) {
    options = {};
  }

  // Default the same as node
  var mode = options.mode || constants.DEFAULT_FILE_MODE;
  var flags = options.flags || 'w';
  var position = APPEND_MODE_REGEXP.test(flags) ? null : 0;

  fs.open(filepath, flags, mode, onOpen);

  function onOpen(openErr, fd) {
    if (openErr) {
      return onComplete(openErr);
    }

    fs.write(fd, data, 0, data.length, position, onComplete);

    function onComplete(writeErr) {
      callback(writeErr, fd);
    }
  }
}
1308900
function fileChanged(status, filepath) {
			// If file was deleted and then re-added, consider it changed.
			if (changedFiles[filepath] === 'deleted' && status === 'added') {
				status = 'changed';
			}
			// Keep track of changed status for later.
			changedFiles[filepath] = status;
			// Emit watch events if anyone is listening
			if (grunt.event.listeners('watch').length > 0) {
				var matchingTargets = [];
				targets.forEach(function(target) {
					if (grunt.file.match(target.files, filepath).length > 0) {
						matchingTargets.push(target.name);
					}
				});
				matchingTargets.forEach(function(matchingTarget) {
					grunt.event.emit('watch', status, filepath, matchingTarget);
				});
			}
			// Keep track of changed status for later.
			changedFiles[filepath] = status;
			// Execute debounced done function.
			done();
		}
492051
function(filepath, source) {
            var parser = parsers.get(path.extname(filepath));
            var type = parser? parser.name : null;

            return  that.applyShortcuts(type, source);
        }