@Override public File deleteFile(String fileName) { if (fileName == null || fileName.length() == 0) { return null; } Iterator<File> it = fileList.iterator(); File file = null; while (it.hasNext()) { file = it.next(); String name = file.getName(); // if a file is found then delete if (fileName.equals(name)) { double result = deleteFile(file); file.setTransactionTime(result); break; } else { file = null; } } return file; }
@Override public boolean renameFile(File file, String newName) { // check whether the new filename is conflicting with existing ones // or not boolean result = false; if (contains(newName)) { return result; } // replace the file name in the file (physical) list File obj = getFile(file.getName()); if (obj == null) { return result; } else { obj.setName(newName); } // replace the file name in the name list Iterator<String> it = nameList.iterator(); while (it.hasNext()) { String name = it.next(); if (name.equals(file.getName())) { file.setTransactionTime(0); nameList.remove(name); nameList.add(newName); result = true; break; } } return result; }
obj.setTransactionTime(seekTime + transferTime);
@Override public double deleteFile(File file) { double result = 0.0; // check if the file is valid or not if (!isFileValid(file, "deleteFile()")) { return result; } double seekTime = getSeekTime(file.getSize()); double transferTime = getTransferTime(file.getSize()); // check if the file is in the storage if (contains(file)) { fileList.remove(file); // remove the file HD nameList.remove(file.getName()); // remove the name from name list currentSize -= file.getSize(); // decrement the current HD space result = seekTime + transferTime; // total time file.setTransactionTime(result); } return result; }
file.setTransactionTime(result); return result;