-
Notifications
You must be signed in to change notification settings - Fork 58
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#108: Zip-file export/backup unfinished feature temporary suspended
- Loading branch information
Showing
9 changed files
with
181 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package de.k3b.io; | ||
|
||
/* | ||
* Copyright (c) 2019 by k3b. | ||
* | ||
* This file is part of AndroFotoFinder. | ||
* | ||
* This program is free software: you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS | ||
* FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with | ||
* this program. If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
|
||
/* abstract api to process an item */ | ||
public interface IItemSaver<T> { | ||
boolean save(T item); | ||
} |
34 changes: 34 additions & 0 deletions
34
fotolib2/src/main/java/de/k3b/media/Media2ExistingFileSaver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package de.k3b.media; | ||
|
||
import java.io.File; | ||
|
||
import de.k3b.io.FileProcessor; | ||
import de.k3b.io.IItemSaver; | ||
|
||
public class Media2ExistingFileSaver implements IItemSaver<IMetaApi> { | ||
private final IItemSaver<File> fileSaver; | ||
public Media2ExistingFileSaver(IItemSaver<File> fileSaver) { | ||
this.fileSaver = fileSaver; | ||
} | ||
|
||
@Override | ||
public boolean save(IMetaApi item) { | ||
if (item != null) { | ||
String path = item.getPath(); | ||
if (path != null) { | ||
return saveFiles(new File(path), | ||
FileProcessor.getExistingSidecarOrNull(path, true), | ||
FileProcessor.getExistingSidecarOrNull(path, false)) > 0; | ||
} | ||
} | ||
return false; | ||
} | ||
|
||
private int saveFiles(File... files) { | ||
int processed = 0; | ||
for (File f: files) { | ||
if ((f != null) && (f.exists()) && f.canRead() && this.fileSaver.save(f)) processed++; | ||
} | ||
return processed; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
fotolib2/src/main/java/de/k3b/media/MediaCsvStringSaver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package de.k3b.media; | ||
|
||
import java.io.PrintWriter; | ||
import java.io.StringWriter; | ||
|
||
public class MediaCsvStringSaver extends MediaCsvSaver{ | ||
private StringWriter result = new StringWriter(); | ||
private PrintWriter writer = new PrintWriter(result); | ||
public MediaCsvStringSaver() { | ||
super(null); | ||
this.setPrinter(writer); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return result.toString(); | ||
} | ||
} |