From 93b63cf3755d3f1295c976c308b81c6340883abb Mon Sep 17 00:00:00 2001
From: Frank Karlitschek <frank@owncloud.org>
Date: Wed, 2 May 2012 00:20:45 +0200
Subject: [PATCH] ported the rest of the OC_Helper calls

---
 apps/bookmarks/appinfo/app.php             |   2 +-
 apps/calendar/appinfo/app.php              |   2 +-
 apps/calendar/templates/calendar.php       |   2 +-
 apps/contacts/ajax/importaddressbook.php   |   6 +-
 apps/contacts/ajax/loadcard.php            |   6 +-
 apps/contacts/appinfo/app.php              |   2 +-
 apps/contacts/index.php                    |   6 +-
 apps/contacts/photo.php                    |   2 +-
 apps/contacts/thumbnail.php                |   2 +-
 apps/external/appinfo/app.php              |   2 +-
 apps/files/admin.php                       |  16 +--
 apps/files/ajax/upload.php                 |   2 +-
 apps/files/appinfo/app.php                 |   2 +-
 apps/files/index.php                       |   6 +-
 apps/files_archive/lib/storage.php         |   2 +-
 apps/files_archive/lib/tar.php             |  12 +--
 apps/files_archive/lib/zip.php             |   2 +-
 apps/files_archive/tests/archive.php       |   8 +-
 apps/files_archive/tests/storage.php       |   2 +-
 apps/files_archive/tests/tar.php           |   2 +-
 apps/files_archive/tests/zip.php           |   2 +-
 apps/files_encryption/lib/proxy.php        |   4 +-
 apps/files_encryption/tests/encryption.php |   4 +-
 apps/files_encryption/tests/stream.php     |   4 +-
 apps/files_external/lib/ftp.php            |   2 +-
 apps/files_external/lib/google.php         |   2 +-
 apps/files_external/lib/swift.php          |   8 +-
 apps/files_external/lib/webdav.php         |   2 +-
 apps/files_external/tests/ftp.php          |   2 +-
 apps/gallery/appinfo/app.php               |   2 +-
 apps/media/appinfo/app.php                 |   2 +-
 apps/user_ldap/user_ldap.php               |   2 +-
 lib/helper.php                             |   3 +-
 lib/public/util.php                        | 115 ++++++++++++++++++++-
 34 files changed, 173 insertions(+), 67 deletions(-)
 mode change 100644 => 100755 apps/contacts/ajax/importaddressbook.php
 mode change 100644 => 100755 apps/files/ajax/upload.php
 mode change 100644 => 100755 apps/files_archive/lib/storage.php
 mode change 100644 => 100755 apps/files_archive/lib/tar.php
 mode change 100644 => 100755 apps/files_archive/tests/archive.php
 mode change 100644 => 100755 apps/files_archive/tests/storage.php
 mode change 100644 => 100755 apps/files_archive/tests/tar.php
 mode change 100644 => 100755 apps/files_archive/tests/zip.php
 mode change 100644 => 100755 apps/files_encryption/tests/encryption.php
 mode change 100644 => 100755 apps/files_encryption/tests/stream.php
 mode change 100644 => 100755 apps/files_external/lib/ftp.php
 mode change 100644 => 100755 apps/files_external/lib/google.php
 mode change 100644 => 100755 apps/files_external/lib/swift.php
 mode change 100644 => 100755 apps/files_external/lib/webdav.php
 mode change 100644 => 100755 apps/files_external/tests/ftp.php
 mode change 100644 => 100755 apps/user_ldap/user_ldap.php

diff --git a/apps/bookmarks/appinfo/app.php b/apps/bookmarks/appinfo/app.php
index 449969d8e5f..246a0d0ecd7 100755
--- a/apps/bookmarks/appinfo/app.php
+++ b/apps/bookmarks/appinfo/app.php
@@ -13,7 +13,7 @@ OC::$CLASSPATH['OC_Search_Provider_Bookmarks'] = 'apps/bookmarks/lib/search.php'
 OC_App::register( array( 'order' => 70, 'id' => 'bookmark', 'name' => 'Bookmarks' ));
 
 $l = new OC_l10n('bookmarks');
-OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OC_Helper::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
+OC_App::addNavigationEntry( array( 'id' => 'bookmarks_index', 'order' => 70, 'href' => OCP\Util::linkTo( 'bookmarks', 'index.php' ), 'icon' => OCP\Util::imagePath( 'bookmarks', 'bookmarks.png' ), 'name' => $l->t('Bookmarks')));
 
 OC_App::registerPersonal('bookmarks', 'settings');
 OCP\Util::addscript('bookmarks','bookmarksearch');
diff --git a/apps/calendar/appinfo/app.php b/apps/calendar/appinfo/app.php
index 9a60aaeeb95..cf1325fad7a 100755
--- a/apps/calendar/appinfo/app.php
+++ b/apps/calendar/appinfo/app.php
@@ -19,7 +19,7 @@ OC_App::addNavigationEntry( array(
   'id' => 'calendar_index',
   'order' => 10,
   'href' => OCP\Util::linkTo( 'calendar', 'index.php' ),
-  'icon' => OC_Helper::imagePath( 'calendar', 'icon.svg' ),
+  'icon' => OCP\Util::imagePath( 'calendar', 'icon.svg' ),
   'name' => $l->t('Calendar')));
 OC_App::registerPersonal('calendar', 'settings');
 OC_Search::registerProvider('OC_Search_Provider_Calendar');
diff --git a/apps/calendar/templates/calendar.php b/apps/calendar/templates/calendar.php
index f8bd91640e5..4285dc0f833 100755
--- a/apps/calendar/templates/calendar.php
+++ b/apps/calendar/templates/calendar.php
@@ -40,7 +40,7 @@
 								<input type="button" value="<?php echo $l->t('Week');?>" id="oneweekview_radio"/>
 								<input type="button" value="<?php echo $l->t('Month');?>" id="onemonthview_radio"/>
 								<input type="button" value="<?php echo $l->t('List');?>" id="listview_radio"/>&nbsp;&nbsp;
-								<img id="loading" src="<?php echo OC_Helper::imagePath('core', 'loading.gif'); ?>" />
+								<img id="loading" src="<?php echo OCP\Util::imagePath('core', 'loading.gif'); ?>" />
 							</div>
 						</form>
 						<form>
diff --git a/apps/contacts/ajax/importaddressbook.php b/apps/contacts/ajax/importaddressbook.php
old mode 100644
new mode 100755
index 5776c801a76..e54d22b9caf
--- a/apps/contacts/ajax/importaddressbook.php
+++ b/apps/contacts/ajax/importaddressbook.php
@@ -9,8 +9,8 @@
 require_once('../../../lib/base.php');
 OC_JSON::checkLoggedIn();
 OC_Util::checkAppEnabled('contacts');
-$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
-$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
+$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
 $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
 
 $freeSpace=OC_Filesystem::free_space('/');
@@ -19,6 +19,6 @@ $maxUploadFilesize = min($maxUploadFilesize ,$freeSpace);
 
 $tmpl = new OC_Template('contacts', 'part.importaddressbook');
 $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
-$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
+$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
 $tmpl->printpage();
 ?>
diff --git a/apps/contacts/ajax/loadcard.php b/apps/contacts/ajax/loadcard.php
index a2660130a25..90ba3f66097 100755
--- a/apps/contacts/ajax/loadcard.php
+++ b/apps/contacts/ajax/loadcard.php
@@ -38,8 +38,8 @@ function debug($msg) {
 OC_JSON::checkLoggedIn();
 OC_JSON::checkAppEnabled('contacts');
 
-$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
-$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
+$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
 $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
 
 $freeSpace=OC_Filesystem::free_space('/');
@@ -51,7 +51,7 @@ $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
 
 $tmpl = new OC_Template('contacts','part.contact');
 $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
-$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
+$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
 $tmpl->assign('adr_types',$adr_types);
 $tmpl->assign('phone_types',$phone_types);
 $tmpl->assign('email_types',$email_types);
diff --git a/apps/contacts/appinfo/app.php b/apps/contacts/appinfo/app.php
index 2c4da2fd6cd..87c36959743 100755
--- a/apps/contacts/appinfo/app.php
+++ b/apps/contacts/appinfo/app.php
@@ -18,7 +18,7 @@ OC_App::addNavigationEntry( array(
   'id' => 'contacts_index',
   'order' => 10,
   'href' => OCP\Util::linkTo( 'contacts', 'index.php' ),
-  'icon' => OC_Helper::imagePath( 'settings', 'users.svg' ),
+  'icon' => OCP\Util::imagePath( 'settings', 'users.svg' ),
   'name' => OC_L10N::get('contact')->t('Contacts') ));
 
 
diff --git a/apps/contacts/index.php b/apps/contacts/index.php
index 8f2a561b312..c018fca764a 100755
--- a/apps/contacts/index.php
+++ b/apps/contacts/index.php
@@ -37,8 +37,8 @@ $phone_types = OC_Contacts_App::getTypesOfProperty('TEL');
 $email_types = OC_Contacts_App::getTypesOfProperty('EMAIL');
 $categories = OC_Contacts_App::getCategories();
 
-$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
-$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
+$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
 $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
 
 $freeSpace=OC_Filesystem::free_space('/');
@@ -59,7 +59,7 @@ OCP\Util::addStyle('contacts','contacts');
 
 $tmpl = new OC_Template( "contacts", "index", "user" );
 $tmpl->assign('uploadMaxFilesize', $maxUploadFilesize);
-$tmpl->assign('uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
+$tmpl->assign('uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
 $tmpl->assign('property_types', $property_types);
 $tmpl->assign('phone_types', $phone_types);
 $tmpl->assign('email_types', $email_types);
diff --git a/apps/contacts/photo.php b/apps/contacts/photo.php
index 12d7f370710..a545afc434b 100755
--- a/apps/contacts/photo.php
+++ b/apps/contacts/photo.php
@@ -16,7 +16,7 @@ OC_Util::checkAppEnabled('contacts');
 function getStandardImage(){
 	OC_Response::setExpiresHeader('P10D');
 	OC_Response::enableCaching();
-	OC_Response::redirect(OC_Helper::imagePath('contacts', 'person_large.png'));
+	OC_Response::redirect(OCP\Util::imagePath('contacts', 'person_large.png'));
 }
 
 $id = isset($_GET['id']) ? $_GET['id'] : null;
diff --git a/apps/contacts/thumbnail.php b/apps/contacts/thumbnail.php
index ab5d160135e..239ec7f4d47 100755
--- a/apps/contacts/thumbnail.php
+++ b/apps/contacts/thumbnail.php
@@ -29,7 +29,7 @@ OC_Util::checkAppEnabled('contacts');
 function getStandardImage(){
 	OC_Response::setExpiresHeader('P10D');
 	OC_Response::enableCaching();
-	OC_Response::redirect(OC_Helper::imagePath('contacts', 'person.png'));
+	OC_Response::redirect(OCP\Util::imagePath('contacts', 'person.png'));
 }
 
 if(!function_exists('imagecreatefromjpeg')) {
diff --git a/apps/external/appinfo/app.php b/apps/external/appinfo/app.php
index b69cc3b2d6b..66116ac4c6e 100755
--- a/apps/external/appinfo/app.php
+++ b/apps/external/appinfo/app.php
@@ -31,5 +31,5 @@ OC_App::register(array('order' => 70, 'id' => 'external', 'name' => 'External'))
 $sites = OC_External::getSites();
 for ($i = 0; $i < sizeof($sites); $i++) {
 	OC_App::addNavigationEntry(
-			array('id' => 'external_index' . ($i + 1), 'order' => 80 + $i, 'href' => OCP\Util::linkTo('external', 'index.php') . '?id=' . ($i + 1), 'icon' => OC_Helper::imagePath('external', 'external.png'), 'name' => $sites[$i][0]));
+			array('id' => 'external_index' . ($i + 1), 'order' => 80 + $i, 'href' => OCP\Util::linkTo('external', 'index.php') . '?id=' . ($i + 1), 'icon' => OCP\Util::imagePath('external', 'external.png'), 'name' => $sites[$i][0]));
 }
diff --git a/apps/files/admin.php b/apps/files/admin.php
index ae7ea0436a0..120e245fd42 100755
--- a/apps/files/admin.php
+++ b/apps/files/admin.php
@@ -29,24 +29,24 @@ OCP\User::checkAdminUser();
 
 $htaccessWorking=(getenv('htaccessWorking')=='true');
 
-$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
-$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
-$maxUploadFilesize = OC_Helper::humanFileSize(min($upload_max_filesize, $post_max_size));
+$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
+$maxUploadFilesize = OCP\Util::humanFileSize(min($upload_max_filesize, $post_max_size));
 if($_POST) {
 	if(isset($_POST['maxUploadSize'])){
-		if(($setMaxSize = OC_Files::setUploadLimit(OC_Helper::computerFileSize($_POST['maxUploadSize']))) !== false) {
-			$maxUploadFilesize = OC_Helper::humanFileSize($setMaxSize);
+		if(($setMaxSize = OC_Files::setUploadLimit(OCP\Util::computerFileSize($_POST['maxUploadSize']))) !== false) {
+			$maxUploadFilesize = OCP\Util::humanFileSize($setMaxSize);
 		}
 	}
 	if(isset($_POST['maxZipInputSize'])) {
 		$maxZipInputSize=$_POST['maxZipInputSize'];
-		OC_Config::setValue('maxZipInputSize', OC_Helper::computerFileSize($maxZipInputSize));
+		OC_Config::setValue('maxZipInputSize', OCP\Util::computerFileSize($maxZipInputSize));
 	}
 	if(isset($_POST['submitFilesAdminSettings'])) {
 		OC_Config::setValue('allowZipDownload', isset($_POST['allowZipDownload']));
 	}
 }
-$maxZipInputSize = OC_Helper::humanFileSize(OC_Config::getValue('maxZipInputSize', OC_Helper::computerFileSize('800 MB')));
+$maxZipInputSize = OCP\Util::humanFileSize(OC_Config::getValue('maxZipInputSize', OCP\Util::computerFileSize('800 MB')));
 $allowZipDownload = intval(OC_Config::getValue('allowZipDownload', true));
 
 OC_App::setActiveNavigationEntry( "files_administration" );
@@ -54,7 +54,7 @@ OC_App::setActiveNavigationEntry( "files_administration" );
 $tmpl = new OC_Template( 'files', 'admin' );
 $tmpl->assign( 'htaccessWorking', $htaccessWorking );
 $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
-$tmpl->assign( 'maxPossibleUploadSize', OC_Helper::humanFileSize(PHP_INT_MAX));
+$tmpl->assign( 'maxPossibleUploadSize', OCP\Util::humanFileSize(PHP_INT_MAX));
 $tmpl->assign( 'allowZipDownload', $allowZipDownload);
 $tmpl->assign( 'maxZipInputSize', $maxZipInputSize);
 return $tmpl->fetchPage();
\ No newline at end of file
diff --git a/apps/files/ajax/upload.php b/apps/files/ajax/upload.php
old mode 100644
new mode 100755
index 3ac8ef59560..c50f6233a46
--- a/apps/files/ajax/upload.php
+++ b/apps/files/ajax/upload.php
@@ -46,7 +46,7 @@ $result=array();
 if(strpos($dir,'..') === false){
 	$fileCount=count($files['name']);
 	for($i=0;$i<$fileCount;$i++){
-        $target = OC_Helper::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
+        $target = OCP\Util::buildNotExistingFileName(stripslashes($dir), $files['name'][$i]);
 		if(is_uploaded_file($files['tmp_name'][$i]) and OC_Filesystem::fromTmpFile($files['tmp_name'][$i],$target)){
 			$meta=OC_FileCache::getCached($target);
 			$result[]=array( "status" => "success", 'mime'=>$meta['mimetype'],'size'=>$meta['size'],'name'=>basename($target));
diff --git a/apps/files/appinfo/app.php b/apps/files/appinfo/app.php
index 40523521d9c..0e82713fe5c 100755
--- a/apps/files/appinfo/app.php
+++ b/apps/files/appinfo/app.php
@@ -5,6 +5,6 @@ $l=OC_L10N::get('files');
 
 OC_App::register( array( "order" => 2, "id" => "files", "name" => "Files" ));
 
-OC_App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OC_Helper::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") ));
+OC_App::addNavigationEntry( array( "id" => "files_index", "order" => 0, "href" => OCP\Util::linkTo( "files", "index.php" ), "icon" => OCP\Util::imagePath( "core", "places/home.svg" ), "name" => $l->t("Files") ));
 
 OC_Search::registerProvider('OC_Search_Provider_File');
diff --git a/apps/files/index.php b/apps/files/index.php
index 9634a725866..3f97317fc5f 100755
--- a/apps/files/index.php
+++ b/apps/files/index.php
@@ -80,8 +80,8 @@ $breadcrumbNav = new OC_Template( "files", "part.breadcrumb", "" );
 $breadcrumbNav->assign( "breadcrumb", $breadcrumb );
 $breadcrumbNav->assign( "baseURL", OCP\Util::linkTo("files", "index.php")."?dir=");
 
-$upload_max_filesize = OC_Helper::computerFileSize(ini_get('upload_max_filesize'));
-$post_max_size = OC_Helper::computerFileSize(ini_get('post_max_size'));
+$upload_max_filesize = OCP\Util::computerFileSize(ini_get('upload_max_filesize'));
+$post_max_size = OCP\Util::computerFileSize(ini_get('post_max_size'));
 $maxUploadFilesize = min($upload_max_filesize, $post_max_size);
 
 $freeSpace=OC_Filesystem::free_space('/');
@@ -95,7 +95,7 @@ $tmpl->assign( 'dir', $dir);
 $tmpl->assign( 'readonly', !OC_Filesystem::is_writable($dir));
 $tmpl->assign( "files", $files );
 $tmpl->assign( 'uploadMaxFilesize', $maxUploadFilesize);
-$tmpl->assign( 'uploadMaxHumanFilesize', OC_Helper::humanFileSize($maxUploadFilesize));
+$tmpl->assign( 'uploadMaxHumanFilesize', OCP\Util::humanFileSize($maxUploadFilesize));
 $tmpl->assign( 'allowZipDownload', intval(OC_Config::getValue('allowZipDownload', true)));
 $tmpl->printPage();
 
diff --git a/apps/files_archive/lib/storage.php b/apps/files_archive/lib/storage.php
old mode 100644
new mode 100755
index 700d9633042..7a4ae339621
--- a/apps/files_archive/lib/storage.php
+++ b/apps/files_archive/lib/storage.php
@@ -104,7 +104,7 @@ class OC_Filestorage_Archive extends OC_Filestorage_Common{
 	}
 	public function touch($path, $mtime=null){
 		if(is_null($mtime)){
-			$tmpFile=OC_Helper::tmpFile();
+			$tmpFile=OCP\Util::tmpFile();
 			$this->archive->extractFile($path,$tmpFile);
 			$this->archive->addfile($path,$tmpFile);
 		}else{
diff --git a/apps/files_archive/lib/tar.php b/apps/files_archive/lib/tar.php
old mode 100644
new mode 100755
index 1eed11a762d..3a07a28906c
--- a/apps/files_archive/lib/tar.php
+++ b/apps/files_archive/lib/tar.php
@@ -93,7 +93,7 @@ class OC_Archive_TAR extends OC_Archive{
 	 */
 	function rename($source,$dest){
 		//no proper way to delete, rename entire archive, rename file and remake archive
-		$tmp=OC_Helper::tmpFolder();
+		$tmp=OCP\Util::tmpFolder();
 		$this->tar->extract($tmp);
 		rename($tmp.$source,$tmp.$dest);
 		$this->tar=null;
@@ -177,7 +177,7 @@ class OC_Archive_TAR extends OC_Archive{
 	 * @return bool
 	 */
 	function extractFile($path,$dest){
-		$tmp=OC_Helper::tmpFolder();
+		$tmp=OCP\Util::tmpFolder();
 		if(!$this->fileExists($path)){
 			return false;
 		}
@@ -185,7 +185,7 @@ class OC_Archive_TAR extends OC_Archive{
 		if($success){
 			rename($tmp.$path,$dest);
 		}
-		OC_Helper::rmdirr($tmp);
+		OCP\Util::rmdirr($tmp);
 		return $success;
 	}
 	/**
@@ -216,9 +216,9 @@ class OC_Archive_TAR extends OC_Archive{
 			return false;
 		}
 		//no proper way to delete, extract entire archive, delete file and remake archive
-		$tmp=OC_Helper::tmpFolder();
+		$tmp=OCP\Util::tmpFolder();
 		$this->tar->extract($tmp);
-		OC_Helper::rmdirr($tmp.$path);
+		OCP\Util::rmdirr($tmp.$path);
 		$this->tar=null;
 		unlink($this->path);
 		$this->reopen();
@@ -237,7 +237,7 @@ class OC_Archive_TAR extends OC_Archive{
 		}else{
 			$ext='';
 		}
-		$tmpFile=OC_Helper::tmpFile($ext);
+		$tmpFile=OCP\Util::tmpFile($ext);
 		if($this->fileExists($path)){
 			$this->extractFile($path,$tmpFile);
 		}elseif($mode=='r' or $mode=='rb'){
diff --git a/apps/files_archive/lib/zip.php b/apps/files_archive/lib/zip.php
index dd94859f089..16f722a734e 100755
--- a/apps/files_archive/lib/zip.php
+++ b/apps/files_archive/lib/zip.php
@@ -169,7 +169,7 @@ class OC_Archive_ZIP extends OC_Archive{
 			}else{
 				$ext='';
 			}
-			$tmpFile=OC_Helper::tmpFile($ext);
+			$tmpFile=OCP\Util::tmpFile($ext);
 			OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
 			if($this->fileExists($path)){
 				$this->extractFile($path,$tmpFile);
diff --git a/apps/files_archive/tests/archive.php b/apps/files_archive/tests/archive.php
old mode 100644
new mode 100755
index 9e99466a521..512afe9e915
--- a/apps/files_archive/tests/archive.php
+++ b/apps/files_archive/tests/archive.php
@@ -55,7 +55,7 @@ abstract class Test_Archive extends UnitTestCase {
 		$textFile=$dir.'/lorem.txt';
 		$this->assertEqual(file_get_contents($textFile),$this->instance->getFile('lorem.txt'));
 		
-		$tmpFile=OC_Helper::tmpFile('.txt');
+		$tmpFile=OCP\Util::tmpFile('.txt');
 		$this->instance->extractFile('lorem.txt',$tmpFile);
 		$this->assertEqual(file_get_contents($textFile),file_get_contents($tmpFile));
 	}
@@ -89,7 +89,7 @@ abstract class Test_Archive extends UnitTestCase {
 		$this->instance=$this->getNew();
 		$fh=$this->instance->getStream('lorem.txt','w');
 		$source=fopen($dir.'/lorem.txt','r');
-		OC_Helper::streamCopy($source,$fh);
+		OCP\Util::streamCopy($source,$fh);
 		fclose($source);
 		fclose($fh);
 		$this->assertTrue($this->instance->fileExists('lorem.txt'));
@@ -109,13 +109,13 @@ abstract class Test_Archive extends UnitTestCase {
 	public function testExtract(){
 		$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
 		$this->instance=$this->getExisting();
-		$tmpDir=OC_Helper::tmpFolder();
+		$tmpDir=OCP\Util::tmpFolder();
 		$this->instance->extract($tmpDir);
 		$this->assertEqual(true,file_exists($tmpDir.'lorem.txt'));
 		$this->assertEqual(true,file_exists($tmpDir.'dir/lorem.txt'));
 		$this->assertEqual(true,file_exists($tmpDir.'logo-wide.png'));
 		$this->assertEqual(file_get_contents($dir.'/lorem.txt'),file_get_contents($tmpDir.'lorem.txt'));
-		OC_Helper::rmdirr($tmpDir);
+		OCP\Util::rmdirr($tmpDir);
 	}
 	public function testMoveRemove(){
 		$dir=OC::$SERVERROOT.'/apps/files_archive/tests/data';
diff --git a/apps/files_archive/tests/storage.php b/apps/files_archive/tests/storage.php
old mode 100644
new mode 100755
index 4d0a83356bd..52d6a4296e9
--- a/apps/files_archive/tests/storage.php
+++ b/apps/files_archive/tests/storage.php
@@ -13,7 +13,7 @@ class Test_Filestorage_Archive_Zip extends Test_FileStorage {
 	private $tmpFile;
 	
 	public function setUp(){
-		$this->tmpFile=OC_Helper::tmpFile('.zip');
+		$this->tmpFile=OCP\Util::tmpFile('.zip');
 		$this->instance=new OC_Filestorage_Archive(array('archive'=>$this->tmpFile));
 	}
 
diff --git a/apps/files_archive/tests/tar.php b/apps/files_archive/tests/tar.php
old mode 100644
new mode 100755
index aa46455e659..c543c226bef
--- a/apps/files_archive/tests/tar.php
+++ b/apps/files_archive/tests/tar.php
@@ -16,7 +16,7 @@ if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){
 		}
 
 		protected function getNew(){
-			return new OC_Archive_TAR(OC_Helper::tmpFile('.tar.gz'));
+			return new OC_Archive_TAR(OCP\Util::tmpFile('.tar.gz'));
 		}
 	}
 }else{
diff --git a/apps/files_archive/tests/zip.php b/apps/files_archive/tests/zip.php
old mode 100644
new mode 100755
index 18a2997c1a5..b22ea3b79e9
--- a/apps/files_archive/tests/zip.php
+++ b/apps/files_archive/tests/zip.php
@@ -16,7 +16,7 @@ if(is_dir(OC::$SERVERROOT.'/apps/files_archive/tests/data')){
 		}
 
 		protected function getNew(){
-			return new OC_Archive_ZIP(OC_Helper::tmpFile('.zip'));
+			return new OC_Archive_ZIP(OCP\Util::tmpFile('.zip'));
 		}
 	}
 }else{
diff --git a/apps/files_encryption/lib/proxy.php b/apps/files_encryption/lib/proxy.php
index 11a6a84e667..cbe88adb5e4 100755
--- a/apps/files_encryption/lib/proxy.php
+++ b/apps/files_encryption/lib/proxy.php
@@ -92,7 +92,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
 				//first encrypt the target file so we don't end up with a half encrypted file
 				OCP\Util::writeLog('files_encryption','Decrypting '.$path.' before writing',OCP\Util::DEBUG);
 				$tmp=fopen('php://temp');
-				OC_Helper::streamCopy($result,$tmp);
+				OCP\Util::streamCopy($result,$tmp);
 				fclose($result);
 				OC_Filesystem::file_put_contents($path,$tmp);
 				fclose($tmp);
@@ -104,7 +104,7 @@ class OC_FileProxy_Encryption extends OC_FileProxy{
 
 	public function postGetMimeType($path,$mime){
 		if(self::isEncrypted($path)){
-			$mime=OC_Helper::getMimeType('crypt://'.$path,'w');
+			$mime=OCP\Util::getMimeType('crypt://'.$path,'w');
 		}
 		return $mime;
 	}
diff --git a/apps/files_encryption/tests/encryption.php b/apps/files_encryption/tests/encryption.php
old mode 100644
new mode 100755
index 13093256717..24b3bbcaf40
--- a/apps/files_encryption/tests/encryption.php
+++ b/apps/files_encryption/tests/encryption.php
@@ -27,14 +27,14 @@ class Test_Encryption extends UnitTestCase {
 		$this->assertNotEqual($encrypted,$source);
 		$this->assertEqual($decrypted,$source);
 
-		$tmpFileEncrypted=OC_Helper::tmpFile();
+		$tmpFileEncrypted=OCP\Util::tmpFile();
 		OC_Crypt::encryptfile($file,$tmpFileEncrypted,$key);
 		$encrypted=file_get_contents($tmpFileEncrypted);
 		$decrypted=OC_Crypt::blockDecrypt($encrypted,$key);
 		$this->assertNotEqual($encrypted,$source);
 		$this->assertEqual($decrypted,$source);
 
-		$tmpFileDecrypted=OC_Helper::tmpFile();
+		$tmpFileDecrypted=OCP\Util::tmpFile();
 		OC_Crypt::decryptfile($tmpFileEncrypted,$tmpFileDecrypted,$key);
 		$decrypted=file_get_contents($tmpFileDecrypted);
 		$this->assertEqual($decrypted,$source);
diff --git a/apps/files_encryption/tests/stream.php b/apps/files_encryption/tests/stream.php
old mode 100644
new mode 100755
index 578b091a36c..225e82c99e8
--- a/apps/files_encryption/tests/stream.php
+++ b/apps/files_encryption/tests/stream.php
@@ -22,7 +22,7 @@ class Test_CryptStream extends UnitTestCase {
 		$file=OC::$SERVERROOT.'/3rdparty/MDB2.php';
 		$source=fopen($file,'r');
 		$target=$this->getStream('test2','w');
-		OC_Helper::streamCopy($source,$target);
+		OCP\Util::streamCopy($source,$target);
 		fclose($target);
 		fclose($source);
 
@@ -44,7 +44,7 @@ class Test_CryptStream extends UnitTestCase {
 			$id=uniqid();
 		}
 		if(!isset($this->tmpFiles[$id])){
-			$file=OC_Helper::tmpFile();
+			$file=OCP\Util::tmpFile();
 			$this->tmpFiles[$id]=$file;
 		}else{
 			$file=$this->tmpFiles[$id];
diff --git a/apps/files_external/lib/ftp.php b/apps/files_external/lib/ftp.php
old mode 100644
new mode 100755
index 802446b4fd8..1618a22ba8a
--- a/apps/files_external/lib/ftp.php
+++ b/apps/files_external/lib/ftp.php
@@ -108,7 +108,7 @@ class OC_FileStorage_FTP extends OC_Filestorage_Common{
 				}else{
 					$ext='';
 				}
-				$tmpFile=OC_Helper::tmpFile($ext);
+				$tmpFile=OCP\Util::tmpFile($ext);
 				OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
 				if($this->file_exists($path)){
 					$this->getFile($path,$tmpFile);
diff --git a/apps/files_external/lib/google.php b/apps/files_external/lib/google.php
old mode 100644
new mode 100755
index 0d6db1987f8..24a9d6c3d52
--- a/apps/files_external/lib/google.php
+++ b/apps/files_external/lib/google.php
@@ -84,7 +84,7 @@ class OC_Filestorage_Google extends OC_Filestorage_Common {
 				curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
 		}
 		if ($isDownload) {
-			$tmpFile = OC_Helper::tmpFile();
+			$tmpFile = OCP\Util::tmpFile();
 			$fp = fopen($tmpFile, 'w');
 			curl_setopt($curl, CURLOPT_FILE, $fp);
 			curl_exec($curl);
diff --git a/apps/files_external/lib/swift.php b/apps/files_external/lib/swift.php
old mode 100644
new mode 100755
index a987d17d799..aaba79d9b7b
--- a/apps/files_external/lib/swift.php
+++ b/apps/files_external/lib/swift.php
@@ -164,7 +164,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
 	 * @return array
 	 */
 	private function getSubContainers($container){
-		$tmpFile=OC_Helper::tmpFile();
+		$tmpFile=OCP\Util::tmpFile();
 		$obj=$this->getSubContainerFile($container);
 		try{
 			$obj->save_to_filename($tmpFile);
@@ -190,7 +190,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
 		if(!$name){
 			return false;
 		}
-		$tmpFile=OC_Helper::tmpFile();
+		$tmpFile=OCP\Util::tmpFile();
 		$obj=$this->getSubContainerFile($container);
 		try{
 			$obj->save_to_filename($tmpFile);
@@ -225,7 +225,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
 		if(!$name){
 			return false;
 		}
-		$tmpFile=OC_Helper::tmpFile();
+		$tmpFile=OCP\Util::tmpFile();
 		$obj=$this->getSubContainerFile($container);
 		try{
 			$obj->save_to_filename($tmpFile);
@@ -501,7 +501,7 @@ class OC_FileStorage_SWIFT extends OC_Filestorage_Common{
 	private function getTmpFile($path){
 		$obj=$this->getObject($path);
 		if(!is_null($obj)){
-			$tmpFile=OC_Helper::tmpFile();
+			$tmpFile=OCP\Util::tmpFile();
 			$obj->save_to_filename($tmpFile);
 			return $tmpFile;
 		}else{
diff --git a/apps/files_external/lib/webdav.php b/apps/files_external/lib/webdav.php
old mode 100644
new mode 100755
index 7a2da5c8ec0..75e5f80d217
--- a/apps/files_external/lib/webdav.php
+++ b/apps/files_external/lib/webdav.php
@@ -150,7 +150,7 @@ class OC_FileStorage_DAV extends OC_Filestorage_Common{
 				}else{
 					$ext='';
 				}
-				$tmpFile=OC_Helper::tmpFile($ext);
+				$tmpFile=OCP\Util::tmpFile($ext);
 				OC_CloseStreamWrapper::$callBacks[$tmpFile]=array($this,'writeBack');
 				if($this->file_exists($path)){
 					$this->getFile($path,$tmpFile);
diff --git a/apps/files_external/tests/ftp.php b/apps/files_external/tests/ftp.php
old mode 100644
new mode 100755
index e30fb9a1c38..d2d3622fa78
--- a/apps/files_external/tests/ftp.php
+++ b/apps/files_external/tests/ftp.php
@@ -23,7 +23,7 @@ if(!is_array($config) or !isset($config['ftp']) or !$config['ftp']['run']){
 		}
 
 		public function tearDown(){
-			OC_Helper::rmdirr($this->instance->constructUrl(''));
+			OCP\Util::rmdirr($this->instance->constructUrl(''));
 		}
 	}
 }
diff --git a/apps/gallery/appinfo/app.php b/apps/gallery/appinfo/app.php
index 8f657576224..ad4723c1425 100755
--- a/apps/gallery/appinfo/app.php
+++ b/apps/gallery/appinfo/app.php
@@ -38,7 +38,7 @@ OC_App::addNavigationEntry( array(
  'id' => 'gallery_index',
  'order' => 20,
  'href' => OCP\Util::linkTo('gallery', 'index.php'),
- 'icon' => OC_Helper::imagePath('core', 'places/picture.svg'),
+ 'icon' => OCP\Util::imagePath('core', 'places/picture.svg'),
  'name' => $l->t('Pictures')));
 
 class OC_GallerySearchProvider extends OC_Search_Provider{
diff --git a/apps/media/appinfo/app.php b/apps/media/appinfo/app.php
index 11aeac2b5b4..5e7a411f677 100755
--- a/apps/media/appinfo/app.php
+++ b/apps/media/appinfo/app.php
@@ -29,6 +29,6 @@ OC_APP::registerPersonal('media','settings');
 
 OC_App::register( array( 'order' => 3, 'id' => 'media', 'name' => 'Media' ));
 
-OC_App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OC_Helper::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music')));
+OC_App::addNavigationEntry(array('id' => 'media_index', 'order' => 2, 'href' => OCP\Util::linkTo('media', 'index.php'), 'icon' => OCP\Util::imagePath('core', 'places/music.svg'), 'name' => $l->t('Music')));
 
 OC_Search::registerProvider('OC_MediaSearchProvider');
diff --git a/apps/user_ldap/user_ldap.php b/apps/user_ldap/user_ldap.php
old mode 100644
new mode 100755
index 1e8dc6aacce..1e454ab682f
--- a/apps/user_ldap/user_ldap.php
+++ b/apps/user_ldap/user_ldap.php
@@ -87,7 +87,7 @@ class OC_USER_LDAP extends OC_User_Backend {
 			$quota = false;
 		}
 		$quota = $quota != -1 ? $quota : $this->ldap_quota_def;
-		OC_Preferences::setValue($uid, 'files', 'quota', OC_Helper::computerFileSize($quota));
+		OC_Preferences::setValue($uid, 'files', 'quota', OCP\Util::computerFileSize($quota));
 	}
 
 	private function setEmail( $uid ) {
diff --git a/lib/helper.php b/lib/helper.php
index c5af76dbe52..82d1017debd 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -528,8 +528,7 @@ class OC_Helper {
      * @param $filename
      * @return string
      */
-    public static function buildNotExistingFileName($path, $filename)
-    {
+    public static function buildNotExistingFileName($path, $filename){
 	    if($path==='/'){
 		    $path='';
 	    }
diff --git a/lib/public/util.php b/lib/public/util.php
index b18f0d2311f..05be41a2a05 100644
--- a/lib/public/util.php
+++ b/lib/public/util.php
@@ -60,10 +60,8 @@ class Util {
 	 * @param bool $html
 	 */
 	public static function sendMail($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='') {
-
 		// call the internal mail class
 		\OC_MAIL::send($toaddress,$toname,$subject,$mailtext,$fromaddress,$fromname,$html=0,$altbody='',$ccaddress='',$ccname='',$bcc='');
-
 	}
 
         /**
@@ -74,10 +72,8 @@ class Util {
 	 * @param int level
          */
         public static function writeLog($app, $message, $level) {
-
                 // call the internal log class
                 \OC_LOG::write($app, $message, $level);
-
         }
 
 
@@ -158,6 +154,117 @@ class Util {
 		return(\OC_Helper::severHost());
 	}
 
+	/**
+	 * @brief Creates path to an image
+	 * @param $app app
+	 * @param $image image name
+	 * @returns the url
+	 *
+	 * Returns the path to the image.
+	 */
+        public static function imagePath( $app, $image ){
+		return(\OC_Helper::imagePath( $app, $image ));
+	}
+
+
+	/**
+	 * @brief Make a human file size
+	 * @param $bytes file size in bytes
+	 * @returns a human readable file size
+	 *
+	 * Makes 2048 to 2 kB.
+	 */
+	public static function humanFileSize( $bytes ){
+		return(\OC_Helper::humanFileSize( $bytes ));
+	}
+
+	/**
+	 * @brief Make a computer file size
+	 * @param $str file size in a fancy format
+	 * @returns a file size in bytes
+	 *
+	 * Makes 2kB to 2048.
+	 *
+	 * Inspired by: http://www.php.net/manual/en/function.filesize.php#92418
+	 */
+	public static function computerFileSize( $str ){
+		return(\OC_Helper::computerFileSize( $str ));
+	}
+
+
+
+	/**
+	 * @brief Recusive deletion of folders
+	 * @param string $dir path to the folder
+	 *
+	 */
+	static function rmdirr($dir) {
+		\OC_Helper::rmdirr( $dir );
+	}
+
+
+	/**
+	 * get the mimetype form a local file
+	 * @param string path
+	 * @return string
+	 * does NOT work for ownClouds filesystem, use OC_FileSystem::getMimeType instead
+	 */
+	static function getMimeType($path){
+		return(\OC_Helper::getMimeType( $path ));
+	}
+
+	/**
+	 * copy the contents of one stream to another
+	 * @param resource source
+	 * @param resource target
+	 * @return int the number of bytes copied
+	 */
+	public static function streamCopy($source,$target){
+		return(\OC_Helper::streamCopy($source,$target));
+	}
+
+
+	/**
+	 * create a temporary file with an unique filename
+	 * @param string postfix
+	 * @return string
+	 *
+	 * temporary files are automatically cleaned up after the script is finished
+	 */
+	public static function tmpFile($postfix=''){
+		return(\OC_Helper::tmpFile($postfix));
+	}
+
+	/**
+	 * create a temporary folder with an unique filename
+	 * @return string
+	 *
+	 * temporary files are automatically cleaned up after the script is finished
+	 */
+	public static function tmpFolder(){
+		return(\OC_Helper::tmpFolder());
+	}
+
+	/**
+	 * Adds a suffix to the name in case the file exists
+	 *
+	 * @param $path
+	 * @param $filename
+	 * @return string
+	 */
+	public static function buildNotExistingFileName($path, $filename){
+		return(\OC_Helper::buildNotExistingFileName($path, $filename));
+	}
+
+
+
+
+
+
+
+
+
+
 
 
 
-- 
GitLab