home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / lang / c / 20336 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  1.7 KB

  1. Xref: sparky comp.lang.c:20336 comp.os.msdos.programmer:12535
  2. Path: sparky!uunet!ferkel.ucsb.edu!taco!rock!stanford.edu!agate!spool.mu.edu!olivea!charnel!psgrain!m2xenix!clark!pacifier!nathans
  3. From: nathans@pacifier.rain.com (Nathan Silva)
  4. Newsgroups: comp.lang.c,comp.os.msdos.programmer
  5. Subject: Re: DOS File Locking
  6. Summary: Summary of replies
  7. Message-ID: <C1JAGL.KIB@pacifier.rain.com>
  8. Date: 27 Jan 93 22:28:52 GMT
  9. Followup-To: comp.os.msdos.programmer
  10. Organization: Pacifier BBS
  11. Lines: 30
  12.  
  13.  
  14. >
  15. >I am writing a small Windows application in Turbo C++.  I'd like
  16. >to lock a region of a file so that other processes can still read
  17. >it, but cannot write to it.  However, when I use the standard
  18. >lock/unlock functions, other processes cannot read the locked region.
  19. >
  20.  
  21. As some of you pointed out, comp.lang.c is not the best newsgroup for
  22. this.  However, since some people asked for a summary, here it is
  23. (followups to comp.os.msdos.programmer).
  24.  
  25. One person suggested adding a one-byte "flag" to the structure that I
  26. am using.  The flag would be used to control access to that particular
  27. record.  This is a good choice if portability is a concern.
  28.  
  29. Another reply described an interesting technique - lock a nonexistent
  30. portion of the file.  For example, to "lock" bytes 250-350, you would
  31. lock (logical) bytes 1,000,000,250 - 1,000,000,350.  This works under
  32. DOS/Windows... I don't know if it's portable.  This is the method I'm
  33. using.
  34.  
  35. There were other replies; thanks to all who replied.
  36.  
  37. Nathan
  38. -- 
  39.  -------------------------------------------------------
  40. | Nathan Silva               |                          |
  41. | nathans@pacifier.rain.com  | Do the World News Polka! |
  42.  -------------------------------------------------------
  43.