comp.lang.ada
 help / color / mirror / Atom feed
From: boobeargrr@aol.com (Joshua Shriver)
Subject: Direct IO Help needed
Date: 27 Feb 2002 11:56:46 GMT
Date: 2002-02-27T11:56:46+00:00	[thread overview]
Message-ID: <20020227065646.12931.00000771@mb-me.aol.com> (raw)

Here is the src I've created, now I need to create a main application that uses
these procedures, how is this done? it seems this is a "generic package" or
something so I can't just use with dfs; use dfs and then do:

dfs.switch_file_lines(...);

Here is the .adb



-- Joshua Shriver
-- Lab 2
-- Direct File Stuff package

with direct_io;

package body dfs is

procedure switch_file_lines(source_file: in string; line1: integer; line2:
integer) is

s_file: dfs_pkg.file_type;
buffer1: item;
buffer2: item;

Begin
	-- Swap file lines
	open(s_file, inout_file, source_file);
	read(s_file, buffer1, positive_count(line1));
	read(s_file, buffer2, positive_count(line2));
	write(s_file, buffer1, positive_count(line2));
	write(s_file, buffer2, positive_count(line1));

	close(s_file);

end switch_file_lines;

procedure swap_head_tail(source_file: in string; lines: integer) is
s_file: dfs_pkg.file_type;
i: integer;
last: count;
Begin
	-- Store file variables
	open(s_file, inout_file, source_file);
	last := size(s_file);
	close(s_file);

	i := 1;
	for i in 1.. lines loop
		switch_file_lines(source_file, i, integer(last));
		last := last - 1;
	end loop;


end swap_head_tail;

procedure get_middle(source_file: in string; found: out item) is
s_file: dfs_pkg.file_type;
middle: count;

Begin

	open(s_file, inout_file, source_file);
	middle := size(s_file) / 2;
	read(s_file, found, middle);	

end get_middle;

end dfs;

Here is the .ads


with direct_io;

generic 
	type item is private;

package dfs is
	package dfs_pkg is new direct_io(item);
        use dfs_pkg;

procedure switch_file_lines(source_file: in string; line1: integer; line2:
integer);

procedure swap_head_tail(source_file: in string; lines: integer);

procedure get_middle(source_file: in string; found: out item);

end dfs;

Any help is appreciated.

Sincerely,
Joshua Shriver
jshriver@mix.wvu.edu




             reply	other threads:[~2002-02-27 11:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-02-27 11:56 Joshua Shriver [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-02-27 12:23 Direct IO Help needed Christoph Grein
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox