Add compatibility to nc 29

master
Jonas Letzbor 2024-07-07 12:48:12 +02:00
parent a63cffff53
commit 60a32057f8
Signed by: RPJosh
GPG Key ID: 43ACB900522EA740
6 changed files with 65 additions and 116 deletions

View File

@ -23,7 +23,7 @@
<database min-version="9.4">pgsql</database>
<database>sqlite</database>
<database min-version="5.5">mysql</database>
<nextcloud min-version="14" max-version="28"/>
<nextcloud min-version="22" max-version="29"/>
</dependencies>
<settings>
<admin>OCA\GpxEdit\Settings\Admin</admin>

View File

@ -17,5 +17,10 @@
"psr-4": {
"OCP\\": "vendor/nextcloud/ocp/OCP"
}
},
"autoload": {
"files": [
"lib/Helper/Functions.php"
]
}
}

View File

@ -27,6 +27,11 @@ use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Controller;
require_once(__DIR__ . '/../Helper/Functions.php');
use function OCA\GpxEdit\Helper\globRecursive;
use function OCA\GpxEdit\Helper\getProgramPath;
use function OCA\GpxEdit\Helper\endswith;
require_once('Conversion.php');
function delTree($dir) {
@ -37,53 +42,6 @@ function delTree($dir) {
return rmdir($dir);
}
/**
* Recursive find files from name pattern
*/
function globRecursive($path, $find, $recursive=True) {
$result = Array();
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if (substr($file, 0, 1) === '.') continue;
$rfile = "{$path}/{$file}";
if (is_dir($rfile) and $recursive) {
foreach (globRecursive($rfile, $find) as $ret) {
array_push($result, $ret);
}
} else {
if (fnmatch($find, $file)){
array_push($result, $rfile);
}
}
}
closedir($dh);
return $result;
}
/*
* search into all directories in PATH environment variable
* to find a program and return it if found
*/
function getProgramPath($progname){
$path_ar = explode(':',getenv('path'));
$path_ar = array_merge($path_ar, explode(':',getenv('PATH')));
foreach ($path_ar as $path){
$supposed_gpath = $path.'/'.$progname;
if (file_exists($supposed_gpath) and
is_executable($supposed_gpath)){
return $supposed_gpath;
}
}
return null;
}
function endswith($string, $test) {
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
}
class PageController extends Controller {
private $userId;

View File

@ -29,52 +29,9 @@ use OCP\AppFramework\Controller;
use function OCP\Log\logger;
/**
* Recursive find files from name pattern
*/
function globRecursive($path, $find, $recursive=True) {
$result = Array();
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if (substr($file, 0, 1) === '.') continue;
$rfile = "{$path}/{$file}";
if (is_dir($rfile) and $recursive) {
foreach (globRecursive($rfile, $find) as $ret) {
array_push($result, $ret);
}
} else {
if (fnmatch($find, $file)){
array_push($result, $rfile);
}
}
}
closedir($dh);
return $result;
}
/*
* search into all directories in PATH environment variable
* to find a program and return it if found
*/
function getProgramPath($progname){
$path_ar = explode(':',getenv('path'));
$path_ar = array_merge($path_ar, explode(':',getenv('PATH')));
foreach ($path_ar as $path){
$supposed_gpath = $path.'/'.$progname;
if (file_exists($supposed_gpath) and
is_executable($supposed_gpath)){
return $supposed_gpath;
}
}
return null;
}
function endswith($string, $test) {
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
}
use function OCA\GpxEdit\Helper\globRecursive;
use function OCA\GpxEdit\Helper\getProgramPath;
use function OCA\GpxEdit\Helper\endswith;
class UtilsController extends Controller {

View File

@ -0,0 +1,50 @@
<?php
namespace OCA\GpxEdit\Helper;
/**
* Recursive find files from name pattern
*/
function globRecursive($path, $find, $recursive=True) {
$result = Array();
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if (substr($file, 0, 1) === '.') continue;
$rfile = "{$path}/{$file}";
if (is_dir($rfile) and $recursive) {
foreach (globRecursive($rfile, $find) as $ret) {
array_push($result, $ret);
}
} else {
if (fnmatch($find, $file)){
array_push($result, $rfile);
}
}
}
closedir($dh);
return $result;
}
/*
* search into all directories in PATH environment variable
* to find a program and return it if found
*/
function getProgramPath($progname){
$path_ar = explode(':',getenv('path'));
$path_ar = array_merge($path_ar, explode(':',getenv('PATH')));
foreach ($path_ar as $path){
$supposed_gpath = $path.'/'.$progname;
if (file_exists($supposed_gpath) and
is_executable($supposed_gpath)){
return $supposed_gpath;
}
}
return null;
}
function endswith($string, $test) {
$strlen = strlen($string);
$testlen = strlen($test);
if ($testlen > $strlen) return false;
return substr_compare($string, $test, $strlen - $testlen, $testlen) === 0;
}

View File

@ -10,28 +10,7 @@ use OCP\Settings\ISettings;
use OCP\Util;
use OCP\IURLGenerator;
/**
* Recursive find files from name pattern
*/
function globRecursive($path, $find, $recursive=True) {
$result = Array();
$dh = opendir($path);
while (($file = readdir($dh)) !== false) {
if (substr($file, 0, 1) === '.') continue;
$rfile = "{$path}/{$file}";
if (is_dir($rfile) and $recursive) {
foreach (globRecursive($rfile, $find) as $ret) {
array_push($result, $ret);
}
} else {
if (fnmatch($find, $file)){
array_push($result, $rfile);
}
}
}
closedir($dh);
return $result;
}
use function OCA\GpxEdit\Helper\globRecursive;
class Admin implements ISettings {