private static FileStatus getFileStatusForAbsentFile(Entry entry) {
   if (entry == null || entry.isDirectory()) {
     return FileStatus.UNKNOWN;
   }
   if (entry.isRemoved()) {
     return FileStatus.DELETED;
   }
   return FileStatus.DELETED_FROM_FS;
 }
Beispiel #2
0
 /**
  * Get the locally deleted files (files which are under version control, and which existed
  * locally, but which have been deleted locally).
  *
  * @param set The set to store the locally deleted files in
  * @param dir The directory to look for deleted files in (non-recursively)
  * @throws IOException
  */
 public void getLocallyDeletedFiles(Set set, File dir) throws IOException {
   Iterator i = adminHandler.getEntries(dir);
   while (i.hasNext()) {
     Entry entry = (Entry) i.next();
     File file = new File(dir, entry.getName());
     if (!file.exists() && !entry.isDirectory()) {
       set.add(new File(dir, entry.getName()));
     }
   }
 }
  public static FileStatus getStatus(VirtualFile file, Entry entry) {
    if (file == null) {
      return getFileStatusForAbsentFile(entry);
    }

    if (entry == null) {
      return getFileStatusForAbsentEntry(file);
    }

    if (entry.isDirectory()) {
      return FileStatus.NOT_CHANGED;
    }

    if (entry.isAddedFile()) {
      return FileStatus.ADDED;
    }

    if (entry.isRemoved()) {
      return FileStatus.DELETED;
    }

    if (entry.isResultOfMerge()) {
      if (entry.isConflict()) {
        return FileStatus.MERGED_WITH_CONFLICTS;
      } else {
        return FileStatus.MERGE;
      }
    }

    Date revisionDate = entry.getLastModified();

    if (revisionDate == null) {
      return FileStatus.MODIFIED;
    }

    final long entryDate = revisionDate.getTime();
    final long fileDate = CvsVfsUtil.getTimeStamp(file);
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "getStatus() for "
              + file.getPath()
              + ": entry date "
              + entryDate
              + ", file date "
              + fileDate);
    }
    return (timeStampsAreEqual(entryDate, fileDate)) ? FileStatus.NOT_CHANGED : FileStatus.MODIFIED;
  }