Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

documentation for new direction_operations

  • Loading branch information...
commit 8cf144fe005c5241c6da7bb24dcff3ebc30583cc 1 parent 3185a5c
@kburtch authored
View
2  ChangeLog
@@ -85,3 +85,5 @@ throw an exception on a number instead of a string as the first parameter.
37. New: mysqlm.append_for_insert and mysqlm.append_for_update procedures that take a record as a parameter.
+38. New: directory_operations.open, close, is_open, read. New data type directory_operations.dir_file_id.
+
View
4 README
@@ -1,5 +1,5 @@
-SparForte (Business Shell) README File
---------------------------------------
+SparForte README File
+---------------------
Ken O. Burtch is the author of "Linux Shell Scripting with Bash" and
former IT Architect with the "Webkinz" brand websites. With nearly 20
View
2  README.md
@@ -1,4 +1,4 @@
-# SparForte (Business Shell) README File
+# SparForte README File
Ken O. Burtch is the author of "Linux Shell Scripting with Bash" and
former IT Architect with the "Webkinz" brand websites. With nearly 20
View
176 doc/pkg_dirops.html
@@ -52,7 +52,8 @@
<a href="#directory_operations.dir_separator">c := dir_separator</a> <a href="#directory_operations.change_dir">change_dir( p )</a> <a href="#directory_operations.remove_dir">remove_dir( p [, r] )</a>
<a href="#directory_operations.get_current_dir">p := get_current_dir</a> <a href="#directory_operations.dir_name">s := dir_name( p )</a> <a href="#directory_operations.base_name">s := base_name( p [, f] )</a>
<a href="#directory_operations.file_extension">s := file_extension( p )</a> <a href="#directory_operations.file_name">s := file_name( p )</a> <a href="#directory_operations.format_pathname">s := format_pathname( p [,t] )</a>
- <a href="#directory_operations.expand_path">s := expand_path( p [,t] )</a> <a href="#directory_operations.make_dir">make_dir( p )</a>
+ <a href="#directory_operations.expand_path">s := expand_path( p [,t] )</a> <a href="#directory_operations.make_dir">make_dir( p )</a> <a href="#directory_operations.close">close( d )</a>
+ <a href="#directory_operations.is_open">b := is_open( d )</a> <a href="#directory_operations.open">open( d, p )</a> <a href="#directory_operations.read">read( d, s )</a>
</pre>
&nbsp;<br>
<div class="code_caption">
@@ -78,6 +79,7 @@
slash or back slash).</li>
<li><b>directory_operations.path_style</b>: the format of a pathname - path_style.unix, path_style.dos, path_style.system_default</li>
<li><b>directory_operations.environment_style</b>: the format for environment variable substitution - environment_style.unix, environment_style.dos, environment_style.both, environment_style.system_default</li>
+<li><b>directory_operations.dir_file_id</b>: the id number of a dir_file resource, allocated by directory_operations.open</li>
</ul>
<a name="directory_operations.base_name"></a><h3>s := directory_operations.base_name( p [, f] )</h3>
@@ -168,6 +170,43 @@
</tr>
</table>
+<a name="directory_operations.close"></a><h3>directory_operations.close( d )</h3>
+<table cellspacing="0" cellpadding="0" width="98%" summary="package call">
+<tr>
+<td width="15%">&nbsp;</td>
+<td><p>Closes a directory referenced by the dir_file id.</p></td>
+</tr><tr>
+<td><p class="pkg_label">Example</p></td>
+<td><span class="code">directory_operations.close( dir );</span></td>
+</tr><tr>
+<td><p class="pkg_label">Parameters</p></td>
+<td><table CELLSPACING=0 CELLPADDING=0 WIDTH="100%" border="0" >
+<tr>
+<td><span class="pkg_param">Param</span></td>
+<td><span class="pkg_param">Mode</span></td>
+<td><span class="pkg_param">Type</span></td>
+<td><span class="pkg_param">Default</span></td>
+<td><span class="pkg_param">Description</span></td>
+</tr><tr>
+<td><span>d</span></td>
+<td><span>in</span></td>
+<td><span>dir_file_id</span></td>
+<td><span>required</span></td>
+<td><span>the id of a directory file resource</span></td>
+</tr>
+</table></td>
+</tr><tr>
+<td><p class="pkg_label">Exceptions</p></td>
+<td><p>An error occurs if the dir_file is not open.</p></td>
+</tr><tr>
+<td><p class="pkg_label">See Also</p></td>
+<td><p><a href="#directory_operations.open">directory_operations.open</a></p></td>
+</tr><tr>
+<td><p class="pkg_label">Compare With</p></td>
+<td><p>Ada: GNAT.Directory_Operations.Open</p></td>
+</tr>
+</table>
+
<a name="directory_operations.dir_name"></a><h3>s := directory_operations.dir_name( p )</h3>
<table cellspacing="0" cellpadding="0" width="98%" summary="package call">
<tr>
@@ -514,6 +553,141 @@
</tr>
</table>
+<a name="directory_operations.is_open"></a><h3>b := directory_operations.is_open( d )</h3>
+<table cellspacing="0" cellpadding="0" width="98%" summary="package call">
+<tr>
+<td width="15%">&nbsp;</td>
+<td><p>Return true if the directory is open.</p></td>
+</tr><tr>
+<td><p class="pkg_label">Example</p></td>
+<td><span class="code">b := directory_operations.is_open( dir );</span></td>
+</tr><tr>
+<td><p class="pkg_label">Parameters</p></td>
+<td><table CELLSPACING=0 CELLPADDING=0 WIDTH="100%" border="0" >
+<tr>
+<td><span class="pkg_param">Param</span></td>
+<td><span class="pkg_param">Mode</span></td>
+<td><span class="pkg_param">Type</span></td>
+<td><span class="pkg_param">Default</span></td>
+<td><span class="pkg_param">Description</span></td>
+</tr><tr>
+<td><span>b</span></td>
+<td><span>return value</span></td>
+<td><span>boolean</span></td>
+<td><span>required</span></td>
+<td><span>true if directory is open</span></td>
+</tr><tr>
+<td><span>d</span></td>
+<td><span>in</span></td>
+<td><span>dir_file_id</span></td>
+<td><span>required</span></td>
+<td><span>the id of a directory file resource</span></td>
+</tr>
+</table></td>
+</tr><tr>
+<td><p class="pkg_label">See Also</p></td>
+<td><p>-</p></td>
+</tr><tr>
+<td><p class="pkg_label">Compare With</p></td>
+<td><p>Ada: GNAT.Directory_Operations.Is_Open</p></td>
+</tr>
+</table>
+
+<a name="directory_operations.open"></a><h3>directory_operations.open( d, p )</h3>
+<table cellspacing="0" cellpadding="0" width="98%" summary="package call">
+<tr>
+<td width="15%">&nbsp;</td>
+<td><p>Opens the directory named p and returns a dir_file id and is
+positioned at the first entry in the directory.</p></td>
+</tr><tr>
+<td><p class="pkg_label">Example</p></td>
+<td><span class="code">directory_operations.open( dir, "/tmp" );</span></td>
+</tr><tr>
+<td><p class="pkg_label">Parameters</p></td>
+<td><table CELLSPACING=0 CELLPADDING=0 WIDTH="100%" border="0" >
+<tr>
+<td><span class="pkg_param">Param</span></td>
+<td><span class="pkg_param">Mode</span></td>
+<td><span class="pkg_param">Type</span></td>
+<td><span class="pkg_param">Default</span></td>
+<td><span class="pkg_param">Description</span></td>
+</tr><tr>
+<td><span>d</span></td>
+<td><span>out</span></td>
+<td><span>dir_file_id</span></td>
+<td><span>required</span></td>
+<td><span>the id of a directory file resource</span></td>
+</tr><tr>
+<td><span>p</span></td>
+<td><span>in</span></td>
+<td><span>string</span></td>
+<td><span>required</span></td>
+<td><span>the pathname of the directory</span></td>
+</tr>
+</table></td>
+</tr><tr>
+<td><p class="pkg_label">Exceptions</p></td>
+<td><p>An error occurs if the directory does not exist or is not accessible.</p></td>
+</tr><tr>
+<td><p class="pkg_label">Implementation Note</p></td>
+<td><p>SparForte strings are not arrays so the length of the string is not returned as it is in Ada.</p></td>
+</tr><tr>
+<td><p class="pkg_label">See Also</p></td>
+<td><p><a href="#directory_operations.close">directory_operations.close</a></p></td>
+</tr><tr>
+<td><p class="pkg_label">Compare With</p></td>
+<td><p>Ada: GNAT.Directory_Operations.Open</p></td>
+</tr>
+</table>
+
+<a name="directory_operations.read"></a><h3>directory_operations.read( d, s )</h3>
+<table cellspacing="0" cellpadding="0" width="98%" summary="package call">
+<tr>
+<td width="15%">&nbsp;</td>
+<td><p>Reads the next entry from the directory and returns the name
+as s. This list includes the "." and ".." directory entries. If s is empty,
+then the end of the directory is reached.</p></td>
+</tr><tr>
+<td><p class="pkg_label">Example</p></td>
+<td><span class="code">directory_operations.read( dir, filename );</span></td>
+</tr><tr>
+<td><p class="pkg_label">Parameters</p></td>
+<td><table CELLSPACING=0 CELLPADDING=0 WIDTH="100%" border="0" >
+<tr>
+<td><span class="pkg_param">Param</span></td>
+<td><span class="pkg_param">Mode</span></td>
+<td><span class="pkg_param">Type</span></td>
+<td><span class="pkg_param">Default</span></td>
+<td><span class="pkg_param">Description</span></td>
+</tr><tr>
+<td><span>d</span></td>
+<td><span>in</span></td>
+<td><span>dir_file_id</span></td>
+<td><span>required</span></td>
+<td><span>the id of a directory file resource</span></td>
+</tr><tr>
+<td><span>s</span></td>
+<td><span>out</span></td>
+<td><span>string</span></td>
+<td><span>required</span></td>
+<td><span>a directory entry</span></td>
+</tr>
+</table></td>
+</tr><tr>
+<td><p class="pkg_label">Exceptions</p></td>
+<td><p>An error occurs if the directory does not exist or is not accessible.</p></td>
+</tr><tr>
+<td><p class="pkg_label">Implementation Note</p></td>
+<td><p>The directory entry is limited to 1024 characters.</p></td>
+</tr><tr>
+<td><p class="pkg_label">See Also</p></td>
+<td><p>-</p></td>
+</tr><tr>
+<td><p class="pkg_label">Compare With</p></td>
+<td><p>Ada: GNAT.Directory_Operations.Read</p></td>
+</tr>
+</table>
+
<a name="directory_operations.remove_dir"></a><h3>directory_operations.remove_dir( p [, r] )</h3>
<table cellspacing="0" cellpadding="0" width="98%" summary="package call">
<tr>
View
2  examples/bases.html
@@ -52,7 +52,7 @@
<b>return</b>;
<b>end</b> <b>if</b>;
<FONT COLOR=green><EM>-- strip off the type and convert hex chars to uppercase</EM></FONT>
- number := `echo $i | sed -e "s/^0[bBxX]//" | tr "[a-f]" "[A-F]";`;
+ number := `echo "$i" | sed -e "s/^0[bBxX]//" | tr "[a-f]" "[A-F]";`;
<FONT COLOR=green><EM>-- convert to base 10 to ensure it's valid</EM></FONT>
dec := `echo "ibase=$ibase; $number" | bc;`;
<FONT COLOR=green><EM>-- if we got a valid result, show the number in other bases</EM></FONT>
View
2  examples/bases.sp
@@ -30,7 +30,7 @@ procedure bases is
return;
end if;
-- strip off the type and convert hex chars to uppercase
- number := `echo $i | sed -e "s/^0[bBxX]//" | tr "[a-f]" "[A-F]";`;
+ number := `echo "$i" | sed -e "s/^0[bBxX]//" | tr "[a-f]" "[A-F]";`;
-- convert to base 10 to ensure it's valid
dec := `echo "ibase=$ibase; $number" | bc;`;
-- if we got a valid result, show the number in other bases
View
3  src/builtins.adb.orig
@@ -1573,7 +1573,8 @@ begin
Put_Line( " c := dir_separator change_dir( p ) remove_dir( p [, r] )" );
Put_Line( " p := get_current_dir s := dir_name( p ) s := base_name( p [, f] )" );
Put_Line( " s := file_extension( p ) s := file_name( p ) s := format_pathname( p [,t] )" );
- Put_Line( " s := expand_path( p [,t] ) make_dir( p )" );
+ Put_Line( " s := expand_path( p [,t] ) make_dir( p ) close( d )" );
+ Put_Line( " b := is_open( d ) open( d, p ) read( d, s )" );
elsif helpTopic = "end_of_file" then
Put_Line( "end_of_file - true if an in_file file has no more data" );
Put_Line( " end_of_file( file )" );
View
8 src/scanner_res.adb.orig
@@ -117,6 +117,10 @@ begin
put_line( "postgresql connection" );
when postgresql_query =>
put_line( "postgresql query" );
+ when complex_number =>
+ put_line( "complex number" );
+ when directory =>
+ put_line( "directory type" );
when memcache_connection =>
put_line( "memcache connection" );
when pen_canvas =>
@@ -189,6 +193,10 @@ begin
#end if;
elsif rp.rt = mysql_query then
Free( rp );
+ elsif rp.rt = directory then
+ if is_open( rp.dir ) then
+ close( rp.dir );
+ end if;
end if;
resHandleList.clear( resHandles, long_integer( id ) );
end clearResource;
View
12 src/scanner_res.ads.orig
@@ -22,14 +22,18 @@
------------------------------------------------------------------------------
with gen_list,
+ Ada.Numerics.Long_Complex_Types,
ada.strings.unbounded,
unchecked_deallocation,
+ gnat.directory_operations,
#if MYSQL
APQ.MySQL.Client,
#end if;
world;
use world,
- ada.strings.unbounded;
+ Ada.Numerics.Long_Complex_Types,
+ ada.strings.unbounded,
+ gnat.directory_operations;
package scanner_res is
@@ -55,6 +59,8 @@ type aResourceType is (
mysql_query,
postgresql_connection,
postgresql_query,
+ complex_number,
+ directory,
memcache_connection,
pen_canvas
);
@@ -94,6 +100,10 @@ type resHandle( rt : aResourceType ) is record
#else
null; -- PostgreSQL support not enabled
#end if;
+ when complex_number =>
+ cn : Complex;
+ when directory =>
+ dir : Dir_Type;
when memcache_connection => null;
when pen_canvas => null;
when none => null;
Please sign in to comment.
Something went wrong with that request. Please try again.