]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.utils/src/org/simantics/utils/FileService.java
Make Write-interfaces as @FunctionalInterface for lambdas
[simantics/platform.git] / bundles / org.simantics.utils / src / org / simantics / utils / FileService.java
1 package org.simantics.utils;
2
3 import java.io.File;
4 import java.io.IOException;
5
6 /**
7  * @author Tuukka Lehtonen
8  */
9 public interface FileService {
10
11         public static interface DeleteOption {}
12
13         public static class EffortOption implements DeleteOption {
14                 public final int maxTries;
15
16                 private EffortOption(int maxTries) {
17                         this.maxTries = maxTries;
18                 }
19
20                 public static EffortOption maxTries(int maxTries) {
21                         return new EffortOption(maxTries);
22                 }
23         }
24
25         /**
26          * Schedules a file to be deleted at some point in the future when the
27          * system allows it to be deleted if ever.
28          * 
29          * @param file
30          * @return an operation handle for tracking the progress of the deletion or
31          *         <code>null</code> if there's a deletion operation scheduled for
32          *         the provided file in the queue or the file does not exist.
33          */
34         IOperation<Boolean, IOException> scheduleDeleteIfExists(File file, DeleteOption... options);
35
36 }