home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
World of Shareware - Software Farm 2
/
wosw_2.zip
/
wosw_2
/
CPROG
/
FCOPY32.ZIP
/
README
< prev
next >
Wrap
Text File
|
1992-06-27
|
4KB
|
98 lines
FCOPY - C function to perform file copies.
Version 3.2
This archive contains the following files:
readme (this file)
fcopy.h (function protoypes and misc. defines)
fcopy.c (source for fcopy)
copyfile.asm (source for actual read/write operations)
truename.asm (source for function to get true pathspec)
strtrim.asm (source to trim leading/trailing spaces)
farread.asm (source to read file into a far buffer)
farwrite.asm (source to write file from a far buffer)
copytest.c (source for demo program)
copytest.exe (demo program)
fcopys.lib (small model library)
fcopyc.lib (compact model library)
fcopym.lib (medium model library)
fcopyl.lib (large model library)
fcopyh.lib (huge model library)
fcopy22.zip (version 2.2 of fcopy)
whats.new (changes since version 2.0)
fcopy is a C function that copies one file to another, much like
the DOS COPY command. It operates on single files only (i.e., does
not accept wildcards). To copy multiple files, fcopy must be used
in a loop with findfirst and findnext functions (included in the
Turbo C++ library -- other compilers have similar names).
This version of fcopy checks to see if the source and target file
names actually refer to the same file (example: file.ext and
.\file.ext are actually the same file). This will prevent fcopy
from attempting to copy a file onto itself; trying to do so will
usually corrupt the file unless it is very small in size.
The primary function fcopy is written in C (source included), and
performs the high level functions of opening and closing files and
allocating memory for the file buffer. All other functions
are written in assembler to be callable from C. Assembler source
for all of these modules is also included.
The assembler modules support all memory models by defining the
symbol _model=[model], where model is small, medium, compact,
large, or huge. For example:
tasm /mx /d_model=large truename
will assemble the truename module using the large memory model.
A function to trim leading and trailing white space from a string
(strtrim) has been included. While not absolutely essential, it
does allow the programmer to ensure that a filespec passed to DOS
has no leading and trailing spaces. For example, the DOS function
to open a file (and the one that finds its truename) will fail if
the filename string has not been trimmed. The demonstration
program uses this function to ensure that fcopy and its supporting
functions work properly.
Usage for the function in a C program is as follows:
#include "fcopy.h"
int fcopy (char *sourcename, char *targetname)
The function returns 0 on success. If fcopy fails, it returns -1
and sets the global variables errno and _doserrno to one of the
following:
EINVFNC Invalid function number (1)
ENOFILE File not found (2)
ENOPATH Path not found (3)
EMFILE Too many open files (4)
EACCESS Permission denied (5)
EBADF Bad file number (6)
ECONTR Memory blocks destroyed (7)
ENOMEM Not enough core (8)
EINVMEM Invalid memory block address (9)
EINVACC Invalid access code (12)
DISKFUL Target disk full (-2)
NOCOPY Cannot copy file onto itself (-3)
See the source code for more information.
A short demo program (COPYTEST.EXE) is included. It prompts the
user for source and target filenames and then performs the copy.
If an error occurs during the copy operation, an error message is
displayed.
To compile the demo program using Turbo C++, use the following
command line (for the small model):
tcc -ms copytest fcopys.lib
Ray Waters
CompuServe ID 72261,33
June 27, 1992