| |
| /pliant/language/stream/filebase1.pli |
| |
| 1 |
# Copyright Hubert Tonneau hubert.tonneau@pliant.cx | |
| 2 |
# | |
| 3 |
# This program is free software; you can redistribute it and/or | |
| 4 |
# modify it under the terms of the GNU General Public License version 2 | |
| 5 |
# as published by the Free Software Foundation. | |
| 6 |
# | |
| 7 |
# This program is distributed in the hope that it will be useful, | |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 10 |
# GNU General Public License for more details. | |
| 11 |
# | |
| 12 |
# You should have received a copy of the GNU General Public License | |
| 13 |
# version 2 along with this program; if not, write to the Free Software | |
| 14 |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
| 15 |
| |
| 16 |
scope "/pliant/language/stream/" "/pliant/language/" "/pliant/admin/" | |
| 17 |
module "ring.pli" | |
| 18 |
| |
| 19 |
| |
| 20 |
public | |
| 21 |
type FileInfo | |
| 22 |
field Str name | |
| 23 |
field Status status | |
| 24 |
field Intn size | |
| 25 |
field DateTime datetime | |
| 26 |
field Str options | |
| 27 |
| |
| 28 |
| |
| 29 |
method fi path -> p | |
| 30 |
arg FileInfo fi ; arg Str p | |
| 31 |
p := fi:name 0 (fi:name search_last "/" -1)+1 | |
| 32 |
| |
| 33 |
method fi name_without_path -> f | |
| 34 |
arg FileInfo fi ; arg Str f | |
| 35 |
f := fi:name (fi:name search_last "/" -1)+1 fi:name:len | |
| 36 |
| |
| 37 |
method fi stripped_name -> e | |
| 38 |
arg FileInfo fi ; arg Str e | |
| 39 |
e := fi:name (fi:name search_last "/" -1)+1 fi:name:len | |
| 40 |
e := e 0 (e search "." e:len) | |
| 41 |
| |
| 42 |
method fi extension -> e | |
| 43 |
arg FileInfo fi ; arg Str e | |
| 44 |
e := fi:name (fi:name search_last "/" -1)+1 fi:name:len | |
| 45 |
e := e (e search "." e:len) e:len | |
| 46 |
| |
| 47 |
| |
| 48 |
method fi is_directory -> d | |
| 49 |
arg FileInfo fi ; arg CBool d | |
| 50 |
d := fi:name:len>0 and (fi:name fi:name:len-1)="/" | |
| 51 |
| |
| 52 |
method fi is_link -> l | |
| 53 |
arg FileInfo fi ; arg CBool l | |
| 54 |
l := fi:options option "link" | |
| 55 |
| |
| 56 |
method fi link -> l | |
| 57 |
arg FileInfo fi ; arg Str l | |
| 58 |
l := fi:options option "link" Str | |
| 59 |
| |
| 60 |
| |
| 61 |
function 'cast Status' info -> s | |
| 62 |
arg FileInfo info ; arg Status s | |
| 63 |
explicit | |
| 64 |
s := info status | |
| 65 |
| |
| 66 |
| |
| 67 |
export '. path' '. name_without_path' '. stripped_name' '. extension' | |
| 68 |
export '. is_directory' '. is_link' '. link' | |
| 69 |
export 'cast Status' | |
| |