0f4009be6754082a09ed3bfc6e384ab88cdef25a
1 /* ownCloud Android client application
2 * Copyright (C) 2012-2013 ownCloud Inc.
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2,
6 * as published by the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package com
.owncloud
.android
.oc_framework
.utils
;
22 import com
.owncloud
.android
.oc_framework
.network
.webdav
.WebdavEntry
;
23 import com
.owncloud
.android
.oc_framework
.operations
.RemoteFile
;
25 import android
.util
.Log
;
27 public class FileUtils
{
29 public static final String PATH_SEPARATOR
= "/";
32 public static String
getParentPath(String remotePath
) {
33 String parentPath
= new File(remotePath
).getParent();
34 parentPath
= parentPath
.endsWith(PATH_SEPARATOR
) ? parentPath
: parentPath
+ PATH_SEPARATOR
;
39 * Validate the fileName to detect if contains any forbidden character: / , \ , < , > , : , " , | , ? , *
43 public static boolean isValidName(String fileName
) {
44 boolean result
= true
;
46 Log
.d("FileUtils", "fileName =======" + fileName
);
47 if (fileName
.contains(PATH_SEPARATOR
) ||
48 fileName
.contains("\\") || fileName
.contains("<") || fileName
.contains(">") ||
49 fileName
.contains(":") || fileName
.contains("\"") || fileName
.contains("|") ||
50 fileName
.contains("?") || fileName
.contains("*")) {
57 * Validate the path to detect if contains any forbidden character: \ , < , > , : , " , | , ? , *
61 public static boolean isValidPath(String path
) {
62 boolean result
= true
;
64 Log
.d("FileUtils", "path ....... " + path
);
65 if (path
.contains("\\") || path
.contains("<") || path
.contains(">") ||
66 path
.contains(":") || path
.contains("\"") || path
.contains("|") ||
67 path
.contains("?") || path
.contains("*")) {
74 * Creates and populates a new {@link RemoteFile} object with the data read from the server.
76 * @param we WebDAV entry read from the server for a WebDAV resource (remote file or folder).
77 * @return New OCFile instance representing the remote resource described by we.
79 public static RemoteFile
fillOCFile(WebdavEntry we
) {
80 RemoteFile file
= new RemoteFile(we
.decodedPath());
81 file
.setCreationTimestamp(we
.createTimestamp());
82 file
.setLength(we
.contentLength());
83 file
.setMimeType(we
.contentType());
84 file
.setModifiedTimestamp(we
.modifiedTimestamp());
85 file
.setEtag(we
.etag());