> how can i access a file structure to retrieve informations about a
What information do you need?
> file ? actually i wanna write a function that search for files using
> C,but it seems that i need to call some low level functions to perform
> that
OK, but what's the problem?
--
Robert Riebisch
Bitte NUR in der Newsgroup antworten!
Please reply to the Newsgroup ONLY!
the name for example, and the problem is how can i access the file
structure using assembler?
Assembly is not C - you said you wanted to search for files in C. For
that you use the functions provided by your compiler's run-time libreary,
usually findfirst() and findnext().
In assembly, you use the corresponding DOS interrupts - consult Ralf
Brown's Interrupt List (google for it).
--
T.E.D. (tda...@mst.edu)
Data files no not normally have a data structure associated with them.
There are exceptions, like Dbase files where the file structure and
the explanation of all the details of each field of each records are
placed in a Data Base standard format at he beginning of the file,
beofre the records.
Very rarely indeed, does any data file contain its own name.
You usually have to know with what name the file is registered in the
directory of a disk device.
If the file is external to the system, then the name should be in a
directory on that removable medium.
A CSV file usually starts with a single record with text column titles
separated either with a TAB or a COMMA character.
This then aids in knowing what are the contents of a particular column
or field of a record.
Any internal commas in the text of a single column header requires
that single or double quotes surround the name.
Once you know the files structure, you may then find it convient to
build a related structure in you program, in order to process records
by using the equivalent to pointer to the fields in the record (a
table of offsets).
.
> the name for example, and the problem is how can i access the file
> structure using assembler?
You still didn't tell, what _file information_ you need.
/*
Alex Russell 1995
alexande...@telus.net
A simple example of scanning down through a directory tree.
Tested with Borland C, MS has similiar functions.
*/
#include <stdio.h>
#include <stdlib.h>
#include <dir.h>
#include <dos.h>
/* ---------------------- scan_files() --------------- September 20,1993 */
void scan_files(char *path)
{
struct ffblk fb;
char start_path[90];
getcwd(start_path, 90);
if ( chdir(path) )
{
printf("ERROR changing to %s\n", path);
exit(1);
}
memset((char *)&fb, 0, sizeof(fb));
// recursively scan down thru the directory tree
if ( !findfirst("*.*", &fb, FA_DIREC) )
{
do
{
if ( *fb.ff_name != '.' )
{
if ( (fb.ff_attrib & FA_DIREC) )
scan_files(fb.ff_name);
else
{
printf("File: %-15.15s", fb.ff_name);
}
}
}
while ( !findnext(&fb) );
}
chdir(start_path);
}
> Jrdman wrote:
>
>> the name for example, and the problem is how can i access the file
>> structure using assembler?
>
> You still didn't tell, what _file information_ you need.
Maybe file attributes?
RBIL->inter61b.zip->Interrup.f
--------D-214300-----------------------------
INT 21 - DOS 2+ - GET FILE ATTRIBUTES
AX = 4300h
DS:DX -> ASCIZ filename
Return: CF clear if successful
CX = file attributes (see #01420)
AX = CX (DR DOS 5.0)
CF set on error
AX = error code (01h,02h,03h,05h) (see #01680 at AH=59h)
Notes: under the FlashTek X-32 DOS extender, the filename pointer is in
DS:EDX
under DR DOS 3.41 and 5.0, attempts to change the subdirectory bit are
simply ignored without an error
BUG: Windows for Workgroups returns error code 05h (access denied) instead
of error code 02h (file not found) when attempting to get the
attributes of a nonexistent file. This causes open() with O_CREAT
and fopen() with the "w" mode to fail in Borland C++.
SeeAlso: AX=4301h,AX=4310h,AX=7143h,AH=B6h,INT 2F/AX=110Fh,INT 60/DI=0517h
Bitfields for file attributes:
Bit(s) Description (Table 01420)
7 shareable (Novell NetWare)
7 pending deleted files (Novell DOS, OpenDOS)
6 unused
5 archive
4 directory
3 volume label
execute-only (Novell NetWare)
2 system
1 hidden
0 read-only
---------------------------
Dirk