| |
| /pliant/admin/file2.pli |
| |
| 1 |
abstract | |
| 2 |
[This is a subpart of ] ; link "file.pli" "file.pli" | |
| 3 |
| |
| 4 |
# Copyright Hubert Tonneau hubert.tonneau@pliant.cx | |
| 5 |
# | |
| 6 |
# This program is free software; you can redistribute it and/or | |
| 7 |
# modify it under the terms of the GNU General Public License version 2 | |
| 8 |
# as published by the Free Software Foundation. | |
| 9 |
# | |
| 10 |
# This program is distributed in the hope that it will be useful, | |
| 11 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 12 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 13 |
# GNU General Public License for more details. | |
| 14 |
# | |
| 15 |
# You should have received a copy of the GNU General Public License | |
| 16 |
# version 2 along with this program; if not, write to the Free Software | |
| 17 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 18 |
| |
| 19 |
scope "/pliant/admin/" "/pliant/install/" | |
| 20 |
module "file.pli" | |
| 21 |
module "execute.pli" | |
| 22 |
| |
| 23 |
method s endswith sub -> yes | |
| 24 |
arg Str s sub ; arg CBool yes | |
| 25 |
yes := s:len>=sub:len and (s s:len-sub:len sub:len)=sub | |
| 26 |
| |
| 27 |
function file_extract file in -> status | |
| 28 |
arg Str file in ; arg Status status | |
| 29 |
var FileInfo fileinfo := file_query file extended | |
| 30 |
if (fileinfo:options option "os_name" Str)="" or fileinfo=undefined | |
| 31 |
return failure | |
| 32 |
var FileInfo ininfo := file_query in extended | |
| 33 |
if ininfo=undefined | |
| 34 |
file_tree_create in | |
| 35 |
ininfo := file_query in extended | |
| 36 |
if ininfo=undefined or (ininfo:options option "os_name" Str)="" or not ininfo:is_directory | |
| 37 |
return failure | |
| 38 |
if (file endswith ".tar.gz") or (file endswith ".tgz") | |
| 39 |
status := shunt (execute "tar -zx -f "+(fileinfo:options option "os_name" Str) path in)=0 success failure | |
| 40 |
eif (file endswith ".tar.bz2") | |
| 41 |
status := shunt (execute "tar -jx -f "+(fileinfo:options option "os_name" Str) path in)=0 success failure | |
| 42 |
eif (file endswith ".tar") | |
| 43 |
status := shunt (execute "tar -x -f "+(fileinfo:options option "os_name" Str) path in)=0 success failure | |
| 44 |
else | |
| 45 |
status := failure | |
| 46 |
| |
| 47 |
alias file_extract file_extract in "/pliant/admin/file.pli" | |
| |