Private function to check
    if a file systeem has already been deleted
543707
def _get_deleted_fs(name, blade):
    '''
    
    '''
    try:
        _fs = _get_fs(name, blade)
        if _fs and _fs.destroyed:
            return _fs
    except rest.ApiException:
        return None
211838
function checkIfFileWasUpdated($file)
    {
        $absoluteFilePath = ROOTPATH . $file;
        if (file_exists($absoluteFilePath)) {
            $fileExtension = pathinfo($file, PATHINFO_EXTENSION);
            $fileName = pathinfo($file, PATHINFO_FILENAME);
            $fileFullName = pathinfo($file, PATHINFO_BASENAME);
            $minifiedFileName = substr($file, 0, -strlen($fileFullName)) . $fileName . '.minified.' . $fileExtension;
            $changeDate = filectime($absoluteFilePath);
            $changeDateMinified = file_exists(ROOTPATH . $minifiedFileName) ? filectime(ROOTPATH . $minifiedFileName)
                : 0;
            if ($changeDateMinified == 0 || $changeDate < $changeDateMinified) {
                return $minifiedFileName;
            }
        }

        return null;
    }
45761
private boolean isUniqueFileResolved(final Set<String> alreadyHandled,
      final String s) {
    return this.uniqueFiles && alreadyHandled.contains(s);
  }
136101
function checkFileExistsSync(filepath){
  var flag = true;

  try {
    fs.accessSync(filepath, fs.F_OK);
  } catch(e){
    flag = false;
  }

  return flag;
}
307096
async function fileExists(path) {
  try {
    const stats = await stat(path);
    return stats.isFile() ? true : false;
  } catch (err) {
    return false;
  }
}
163910
function fileEventListener(curr, prev) {
    
    that.emit('access', curr, prev);
      
    if (curr.nlink === 0) {
    
      that.emit('destroy', curr, prev);
      
    }
    
    if (+curr.mtime != +prev.mtime) {  
      
      if (curr.isDirectory() && prev.isDirectory()) {
        
        if (curr.nlink > prev.nlink) {
          
          that.emit('add', curr, prev);
          
        } else if (curr.nlink < prev.nlink) {
          
          that.emit('delete', curr, prev);
          
        }
         
      }
      
      that.emit('change', curr, prev);
    
    }
  
  }
1018816
public static function cleanupNotRemovedFiles()
    {
        $timeOneWeekAgo = strtotime('-1 week');

        $files = _glob(self::getTmpPath() . '/*');
        if (empty($files)) {
            return;
        }

        foreach ($files as $file) {
            if (file_exists($file)) {
                $timeLastModified = filemtime($file);

                if ($timeLastModified !== false && $timeOneWeekAgo > $timeLastModified) {
                    unlink($file);
                }
            }
        }
    }
1266188
def _deleted_files():
    '''
    

    '''
    deleted_files = []

    for proc in psutil.process_iter():  # pylint: disable=too-many-nested-blocks
        try:
            pinfo = proc.as_dict(attrs=['pid', 'name'])
            try:
                with salt.utils.files.fopen('/proc/{0}/maps'.format(pinfo['pid'])) as maps:  # pylint: disable=resource-leakage
                    dirpath = '/proc/' + six.text_type(pinfo['pid']) + '/fd/'
                    listdir = os.listdir(dirpath)
                    maplines = maps.readlines()
            except (OSError, IOError):
                yield False

            # /proc/PID/maps
            mapline = re.compile(r'^[\da-f]+-[\da-f]+ [r-][w-][x-][sp-] '
                                 r'[\da-f]+ [\da-f]{2}:[\da-f]{2} (\d+) *(.+)( \(deleted\))?\n$')

            for line in maplines:
                line = salt.utils.stringutils.to_unicode(line)
                matched = mapline.match(line)
                if not matched:
                    continue
                path = matched.group(2)
                if not path:
                    continue
                valid = _valid_deleted_file(path)
                if not valid:
                    continue
                val = (pinfo['name'], pinfo['pid'], path[0:-10])
                if val not in deleted_files:
                    deleted_files.append(val)
                    yield val

            # /proc/PID/fd
            try:
                for link in listdir:
                    path = dirpath + link
                    readlink = os.readlink(path)
                    filenames = []

                    if os.path.isfile(readlink):
                        filenames.append(readlink)
                    elif os.path.isdir(readlink) and readlink != '/':
                        for root, dummy_dirs, files in salt.utils.path.os_walk(readlink, followlinks=True):
                            for name in files:
                                filenames.append(os.path.join(root, name))

                    for filename in filenames:
                        valid = _valid_deleted_file(filename)
                        if not valid:
                            continue
                        val = (pinfo['name'], pinfo['pid'], filename)
                        if val not in deleted_files:
                            deleted_files.append(val)
                            yield val
            except OSError:
                pass

        except psutil.NoSuchProcess:
            pass
750912
def _check_file(self):
        
        try:
            self.editor.toPlainText()
        except RuntimeError:
            self._timer.stop()
            return
        if self.editor and self.editor.file.path:
            if not os.path.exists(self.editor.file.path) and self._mtime:
                self._notify_deleted_file()
            else:
                mtime = os.path.getmtime(self.editor.file.path)
                if mtime > self._mtime:
                    self._mtime = mtime
                    self._notify_change()
                # check for permission change
                writeable = os.access(self.editor.file.path, os.W_OK)
                self.editor.setReadOnly(not writeable)
224432
function fileExists(file) {
    var fileExists = true;

    try {
        fs.statSync(file, function(err, stat) {
            if (err == null) {
                fileExists = true;
            } else {
                fileExists = false;
            }
        });
    } catch (e) {
        fileExists = false;
    }

    return fileExists;
}
272660
function ensureExistsAndClean (dir) {
  if (!fs.existsSync(dir)) {
    fs.mkdirSync(dir)
  } else {
    cleanDir(dir)
  }
}
307273
static private void checkDuplication(FileSystem fs, Path file, Path sorted,
    Configuration conf) throws IOException {
    SequenceFile.Reader in = null;
    try {
      SequenceFile.Sorter sorter = new SequenceFile.Sorter(fs,
        new Text.Comparator(), Text.class, Text.class, conf);
      sorter.sort(file, sorted);
      in = new SequenceFile.Reader(fs, sorted, conf);

      Text prevdst = null, curdst = new Text();
      Text prevsrc = null, cursrc = new Text(); 
      for(; in.next(curdst, cursrc); ) {
        if (prevdst != null && curdst.equals(prevdst)) {
          throw new DuplicationException(
            "Invalid input, there are duplicated files in the sources: "
            + prevsrc + ", " + cursrc);
        }
        prevdst = curdst;
        curdst = new Text();
        prevsrc = cursrc;
        cursrc = new Text();
      }
    }
    finally {
      checkAndClose(in);
    }
  }
817255
def _disappeared(self, fd, path, **params):
        
        log = self._getparam('log', self._discard, **params)

        log.debug("Path %r removed or renamed, handling removal", path)
        self._close(fd)
        if self._mode == WF_POLLING and fd in self._poll_stat:
            del self._poll_stat[fd]
        if self._mode == WF_INOTIFYX and path in self._inx_inode:
            del self._inx_inode[path]
        del self.fds_open[fd]
        del self.paths_open[path]
        if self.paths[path]:
            try:
                if self._add_file(path, **params):
                    log.debug("Path %r immediately reappeared, pending transition skipped", path)
                    return
            except Exception as e:
                log.debug("Path %r reappearance check failed -- %s", path, e)
            log.debug("Path %r marked as pending", path)
            self.paths_pending[path] = True
        else:
            del self.paths[path]
            raise Exception("Path %r has been removed or renamed" % path)
130118
def on_modified(self, event, dry_run=False, remove_uploaded=True):
        ' '
        super(ArchiveEventHandler, self).on_modified(event)
        src_path = event.src_path
        if event.is_directory:
            if not platform.is_darwin():
                log.info("event is a directory, safe to ignore")
                return
            # OSX is behaving erratically and we need to paper over it.
            # the OS only reports every other file event,
            # but always fires off a directory event when a file has changed. (OSX 10.9 tested)
            # so we need to find the actual file changed and then go on from there
            files = [event.src_path+"/"+f for f in os.listdir(event.src_path)]
            try:
                src_path = max(files, key=os.path.getmtime)
            except (OSError, ValueError) as e: # broken symlink or directory empty
                return
        log.info('Modified file detectd: %s', src_path)
        #
        # we're receiving events at least two times: on file open and on file close.
        # OSes might report even more
        # we're only interested in files that are closed (finished), so we try to
        # open it. if it is locked, we can infer that someone is still writing to it.
        # this works on platforms: windows, ... ?
        # TODO: investigate http://stackoverflow.com/a/3876461 for POSIX support
        try:
            open(src_path)   # win exclusively
            os.open(src_path, os.O_EXLOCK) # osx exclusively
        except IOError: # file is not finished
            log.info('File is not finished')
            return
        except AttributeError: # no suuport for O_EXLOCK (only BSD)
            pass
        return self._new(src_path, dry_run, remove_uploaded)
497246
def safe_delete(filename):
  """"""
  try:
    os.unlink(filename)
  except OSError as e:
    if e.errno != errno.ENOENT:
      raise
593911
def already_downloaded(track, title, filename):
    
    global arguments
    already_downloaded = False

    if os.path.isfile(filename):
        already_downloaded = True
    if arguments['--flac'] and can_convert(filename) \
                           and os.path.isfile(filename[:-4] + ".flac"):
        already_downloaded = True
    if arguments['--download-archive'] and in_download_archive(track):
        already_downloaded = True

    if arguments['--flac'] and can_convert(filename) and os.path.isfile(filename):
        already_downloaded = False

    if already_downloaded:
        if arguments['-c'] or arguments['--remove']:
            logger.info('Track "{0}" already downloaded.'.format(title))
            return True
        else:
            logger.error('Track "{0}" already exists!'.format(title))
            logger.error('Exiting... (run again with -c to continue)')
            sys.exit(0)
    return False
930372
def remove_if_exist(path):  # pragma: no cover
    """"""
    if os.path.exists(path):
        if os.path.isdir(path):
            shutil.rmtree(path)
            return True
        elif os.path.isfile(path):
            os.remove(path)
            return True
    return False