Skip to content

Commit

Permalink
added the .s .z and .e file test methods for Str
Browse files Browse the repository at this point in the history
  • Loading branch information
ShimmerFairy authored and colomon committed Mar 3, 2010
1 parent 32a9461 commit f6092e9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/builtins/Str.pir
Expand Up @@ -216,6 +216,46 @@ Returns the identify value.
.return ($S0)
.end

=item File Test Methods

These return various information about the file.

=cut

.namespace ['Str']
.sub 'e' :method
#does it exist?
.local string filename
filename = self
$I42 = stat filename, 0
if $I42 goto lisreal
$P0 = get_hll_global ['Bool'], 'False'
.return ($P0)
lisreal:
$P0 = get_hll_global ['Bool'], 'True'
.return ($P0)
.end

.sub 'z' :method
#is the length of this file zero?
.local string filename
filename = self
$I42 = stat filename, 1
if $I42==0 goto worthnothing
$P0 = get_hll_global ['Bool'], 'False'
.return ($P0)
worthnothing:
$P0 = get_hll_global ['Bool'], 'True'
.return($P0)
.end

.sub 's' :method
#how big is the file (in bytes)?
.local string filename
filename = self
$I42 = stat filename, 1
.return($I42) #if we need a conditional to return a special type of False instead of just 0, then look up
.end

=back

Expand Down

0 comments on commit f6092e9

Please sign in to comment.