1 package com.introlab.rtabmap;
3 import java.io.BufferedInputStream;
4 import java.io.BufferedOutputStream;
6 import java.io.FileInputStream;
7 import java.io.FileOutputStream;
8 import java.io.FilenameFilter;
9 import java.io.IOException;
10 import java.util.Arrays;
11 import java.util.zip.ZipEntry;
12 import java.util.zip.ZipOutputStream;
14 import android.content.Context;
15 import android.net.ConnectivityManager;
16 import android.net.NetworkInfo;
17 import android.util.Log;
23 public static void zip(String file, String zipFile)
throws IOException {
25 String[] files =
new String[1];
30 public static void zip(String[] files, String zipFile)
throws IOException {
31 Log.i(
RTABMapActivity.
TAG,
"Zipping " + String.valueOf(files.length) +
" files to " + zipFile);
32 BufferedInputStream origin = null;
33 ZipOutputStream out =
new ZipOutputStream(
new BufferedOutputStream(
new FileOutputStream(zipFile)));
37 for (
int i = 0; i < files.length; i++) {
38 FileInputStream fi =
new FileInputStream(files[i]);
39 origin =
new BufferedInputStream(fi, ZIP_BUFFER_SIZE);
41 ZipEntry entry =
new ZipEntry(files[i].substring(files[i].lastIndexOf(
"/") + 1));
42 out.putNextEntry(entry);
44 while ((count = origin.read(data, 0, ZIP_BUFFER_SIZE)) != -1) {
45 out.write(data, 0, count);
58 public static String[]
loadFileList(String directory,
final boolean databasesOnly) {
59 File path =
new File(directory);
64 catch(SecurityException
e) {
68 FilenameFilter filter =
new FilenameFilter() {
71 public boolean accept(File dir, String filename) {
72 File sel =
new File(dir, filename);
84 fileList = path.list(filter);
85 Arrays.sort(fileList);
88 fileList =
new String[0];
109 String[] vals1 = str1.split(
"\\.");
110 String[] vals2 = str2.split(
"\\.");
113 while (i < vals1.length && i < vals2.length && vals1[i].equals(vals2[i])) {
117 if (i < vals1.length && i < vals2.length) {
118 int diff = Integer.valueOf(vals1[i]).compareTo(Integer.valueOf(vals2[i]));
119 return Integer.signum(diff);
123 return Integer.signum(vals1.length - vals2.length);
static final String RTABMAP_TMP_DB
GLM_FUNC_DECL genType e()
static void zip(String file, String zipFile)
static void zip(String[] files, String zipFile)
static String[] loadFileList(String directory, final boolean databasesOnly)
static final int ZIP_BUFFER_SIZE
static int versionCompare(String str1, String str2)