Updated 'always download' item in context menu on list of files to 'download / refres...
[pub/Android/ownCloud.git] / src / com / owncloud / android / utils / FileStorageUtils.java
1 /* ownCloud Android client application
2 * Copyright (C) 2012 Bartek Przybylski
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 *
17 */
18
19 package com.owncloud.android.utils;
20
21 import java.io.File;
22
23 import android.net.Uri;
24 import android.os.Environment;
25 import com.owncloud.android.datamodel.OCFile;
26
27
28 public class FileStorageUtils {
29
30 public static final String getSavePath(String accountName) {
31 File sdCard = Environment.getExternalStorageDirectory();
32 return sdCard.getAbsolutePath() + "/owncloud/" + Uri.encode(accountName, "@");
33 // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
34 }
35
36 public static final String getDefaultSavePathFor(String accountName, OCFile file) {
37 return getSavePath(accountName) + file.getRemotePath();
38 }
39
40 public static final String getTemporalPath(String accountName) {
41 File sdCard = Environment.getExternalStorageDirectory();
42 return sdCard.getAbsolutePath() + "/owncloud/tmp/" + Uri.encode(accountName, "@");
43 // URL encoding is an 'easy fix' to overcome that NTFS and FAT32 don't allow ":" in file names, that can be in the accountName since 0.1.190B
44 }
45
46
47 }