X-Git-Url: http://git.linex4red.de/pub/Android/ownCloud.git/blobdiff_plain/435b31ba4f3597cc7a43270cd4a54fb0180956c1..c4b842f8acdf7d23fa43daf7858ebf68d5a61e21:/src/eu/alefzero/webdav/WebdavUtils.java diff --git a/src/eu/alefzero/webdav/WebdavUtils.java b/src/eu/alefzero/webdav/WebdavUtils.java index dc407b0a..132a1f92 100644 --- a/src/eu/alefzero/webdav/WebdavUtils.java +++ b/src/eu/alefzero/webdav/WebdavUtils.java @@ -1,10 +1,10 @@ /* ownCloud Android client application * Copyright (C) 2012 Bartek Przybylski + * Copyright (C) 2012-2013 ownCloud Inc. * * 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. + * it under the terms of the GNU General Public License version 2, + * as published by the Free Software Foundation. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -23,6 +23,8 @@ import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +import android.net.Uri; + public class WebdavUtils { public static final SimpleDateFormat DISPLAY_DATE_FORMAT = new SimpleDateFormat( "dd.MM.yyyy hh:mm"); @@ -55,4 +57,20 @@ public class WebdavUtils { } return null; } + + /** + * Encodes a path according to URI RFC 2396. + * + * If the received path doesn't start with "/", the method adds it. + * + * @param remoteFilePath Path + * @return Encoded path according to RFC 2396, always starting with "/" + */ + public static String encodePath(String remoteFilePath) { + String encodedPath = Uri.encode(remoteFilePath, "/"); + if (!encodedPath.startsWith("/")) + encodedPath = "/" + encodedPath; + return encodedPath; + } + }