| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | sharing a file |
PL> I'm writing a program that gathers info from a log file,
PL> the problem being that the log file is in use by the
PL> program when my program is run.
You need to have the program that's writing the log open it as write-only,
deny write; then other programs can open the file for concurrent reading.
PL> I get a "disk locked" error when I try reading from it. I
PL> have share loaded, but I haven't done anything to 'share'
PL> the file as such. I'm guessing that is what I have to do?
Yes.
PL> I'd appreciate some info in regards to being able to access
PL> the file at the same time another one has access to it.
As well as the above, you need to then access the file as readonly, deny
none. Look up the values and use of FileMode. To make it easier, I'll
post a couple of messages from the collection, which should help clarify:
Z3_PASCAL -------------------------------------------------------------
Date: 19 Feb 92 16:08:00
From: david begley, 3:712/211.3{at}fidonet
To: David Hulse, 3:681/870.2{at}fidonet
Subj: Programming on a Network
> Some of the files are Text type files, which most are untyped files. If
> I open them using Reset(), then they will be opened in read-
> write mode by default. I set the FileMode variable to 0 which is
> supposed to cause them to be opened in read-only mode. I would have
> assumed that doing this would allow simultaneous access by all users.
Setting the FileMode to zero sets the upper five bits of the access mode to
zero, which selects "compatibility mode" (or old-style) sharing.
To use full
sharing features, you must:
a) ensure you are running under DOS 3 or higher;
uses
Dos;
{...}
if Lo(DosVersion) < 3 then
begin
WriteLn('This programme requires MS-DOS 3.00 or higher.');
Halt(1)
end;
b) ensure SHARE.EXE is loaded;
function ShareLoaded : Boolean; assembler;
asm
xor bh, bh
mov ax, 1000h
int 2Fh
cmp al, 0FFh
jne {at}{at}1
inc bh
{at}{at}1:
mov ah, bh
end; { ShareLoaded }
{...}
if not ShareLoaded then
begin
WriteLn('This programme requires SHARE.EXE to be loaded.');
Halt(1)
end;
c) Supply the correct sharing-mode access code;
76543210 Bits
.....000 Read access
.....001 Write access
.....010 Read/write access
....x... Reserved
.000.... Sharing mode - compatibility mode
.001.... Sharing mode - read/write access denied
.010.... Sharing mode - write access denied
.011.... Sharing mode - read access denied
.100.... Sharing mode - full access permitted
0....... Inherited by child processes
1....... Private to current process
Errm.. questions? :-)
%% david %%
-=-
= Origin: dance you savages! (3:712/211.3)
SEEN-BY: 633/267 270@PATH: 626/660 711/401 808 50/99 635/544 727 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.