home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 8
/
CDASC08.ISO
/
NEWS
/
554
/
JUILLET
/
SHARING.TXT
< prev
next >
Wrap
Text File
|
1993-10-07
|
4KB
|
91 lines
─ Fido Pascal Conference ────────────────────────────────────────────── PASCAL ─
Msg : 61 of 62
From : Daniel Stark 1:243/31.0 30 Jun 93 00:38
To : Mike Kogge 1:260/410.0
Subj : Locking
────────────────────────────────────────────────────────────────────────────────
Hello Mike!
Sunday June 27 1993 17:28, Mike Kogge wrote to All:
MK> @REG: TE-1.b/UR
MK> I am currently writing a BBS in BP 7.0. The problem is, I have no idea on
MK> how to and what files to lock.
MK> I have TPSHAR200.ZIP, but that didn't help much in explaining the
MK> deny/read only, etc. commands. What would I have to lock? What type of
MK> files? When do I unlock them?
MK> 1.. Would I lock display files to read only?
MK> 2.. Locking the message base to read only, unlock when a user writes,
MK> the relock? 3. Lock the file lists to read only? 4. Lock the users file to
MK> read only, yet when nessecary unlock it and then write to it, then relcok
MK> 5. Do I need to lock the files avail to dload?
MK> Please help me here. Also, must I lock at a certain point in the file? I
MK> know STANDARD PASCAL, and taught myself OOP, but some of this stuff is new
MK> to me.
MK> Thanks alot. I appreciate ANY help given.
File sharing
------------
(Shortly explained by jonny bergdahl, 2:204/503)
When sharing files concurrently, by means of for example a multitasker or a
network, it is necessary to use the file sharing as provided by the DOS command
SHARE, or as provided by a Network shell (In Novell file sharing is supported
by
the network shell on Servers, not locally. Check your network documentation for
more information).
File sharing is simple in TP/BP, since the system variable FileMode defines in
what mode a certain file is opened in:
Const
fmReadOnly = $00; (* *)
fmWriteOnly = $01; (* Only one of these should be used *)
fmReadWrite = $02; (* *)
fmDenyAll = $10; (* together with only one of these *)
fmDenyWrite = $20; (* *)
fmDenyRead = $30; (* *)
fmDenyNone = $40; (* *)
fmNoInherit = $70; (* Set for "No inheritance" *)
Construction the FileMode variable is easy, just add the appropriate values:
FileMode:=fmReadOnly+fmDenyNone;
(Open file for reading only, allow read and write.)
FileMode:=fmReadWrite+fmDenyWrite;
(Open file for both read and write, deny write.)
FileMode:=fmReadWrite+fmDenyAll;
(Open file for both read and write, deny all.)
Say you open the file in "fmReadWrite+fmDenyWrite". This will let you read and
write freely in the file, while other processes can freely read the file. If
another process tries to open the file for writing, that process will get the
error "Access denied".
(fmNoInherit is seldom used - it defines if a childprocess spawn from your
process will be able to use the filehandle provided by your process.)
The FileMode variable is only used when the file is opened;
...
Assign(F,FileName);
FileMode:=fmReadOnly+fmDenyNone;
Reset(F);
FileMode:=<Whatever> (* Changing FileMode here does not affect the
files already opened *)
By default, FileMode is defined as FileMode:=$02 in TP/BP, this is referred to
as "compatibility mode" in the TP/BP docs. Two processes accessing the same
file
with this filemode results in the critical error "Sharing violation".