Forum > Suggestions

RTL: FileLockRegion ()

(1/2) > >>

joho:
Is there any way to do regional (or "byte count") file locking with FP? If not, will there be?

These translate to LockFile () in Windows and DosSetFileLocks () in OS/2. For DOS, I believe it's function $5C.

(I'm not talking about file locking by using different open modes, I'm talking about locking a section of a file)

marcov:
Not abstracted, should go via OS specific apis.

There are locking possibilities on Linux, but IIRC they were not very practical (fpflock for whole file, and fcntl F_SETLK locks for byte ranges). But that is just heresay, never did it myself. 

Thaddy:
You ask a lot of questions about features that even an advanced programmer never, if ever, needs.
Since you do so, I expect you can solve any further programming yourself and just explain the basics:
- What you are asking for is technically a window on the data. Look for a windowed stream (there are many)
- On a low level you can achieve this under linux with https://www.freepascal.org/docs-html/3.0.0/rtl/baseunix/fpmmap.html and under Windows similarly with https://msdn.microsoft.com/en-us/library/windows/desktop/aa366556(v=vs.85).aspx 

There's no point in having this unified, because, as I explained, it is not often necessary and when you need it, do it on the OS level. (As Marco suggested)
And I really wonder if you need it: properly written concurrency - in user space - does not need it!

From your questions, I deduct you are not a Noob (at all) . You require some brushing up on proper software design, though.

But there you go. Should be enough. O:-)

joho:
Thank you both for responding.

I'm not trying to point out flaws or faults in FP, quite the contrary. I'm asking questions mainly related to porting a big application from Borland Pascal / Virtual Pascal to Free Pascal. In that process (or attempted process), I run across quite a few question marks. I can of course just keep my mouth shut and go on my merry way and continue doing "my own I/O" (for example). But if the tables were turned, I for one would appreciate questions of a different nature, even if they require my explaining :)

There are many ways of doing most things, and I think that learning as many of them as possible is often a good idea, if for nothing else then to avoid being stuck in the same frame of mind. "Proper software design" is an interesting subject, and I'm guessing there are more theories about that than there are so-called programmers.

I don't know what an "advanced programmer" is, but I can't see how disqualifying someone else's needs just because they don't agree with your own opinions is a very fruitful direction to take. When I started coding (1983), there very few "best practice" things around ... so, you make up your own best practice. I'm glad to see things evolve.

Most of the time, I think you'll find that my questions are actually meant to ask people who have more knowledge of FP than I what "Best practice" (in a FP context) is. That, at least, is my only intention.

If I stepped on someone's toes, then I apologize.

Thaddy:

--- Quote from: joho on September 04, 2017, 04:32:35 pm ---I'm not trying to point out flaws or faults in FP, quite the contrary. I'm asking questions mainly related to porting a big application from Borland Pascal / Virtual Pascal to Free Pascal.

--- End quote ---
Virtual Pascal is an issue, then, because Borland Pascal translates almost flawless. Virtual Pascal is also not maintained... (doesn't even work anymore on some platforms) and was programmed in C.

--- Quote ---There are many ways of doing most things, and I think that learning as many of them as possible is often a good idea, if for nothing else then to avoid being stuck in the same frame of mind. "Proper software design" is an interesting subject, and I'm guessing there are more theories about that than there are so-called programmers.

--- End quote ---
Studying computer science may be a good idea after all 8-)

--- Quote ---I don't know what an "advanced programmer" is, but I can't see how disqualifying someone else's needs just because they don't agree with your own opinions is a very fruitful direction to take. When I started coding (1983), there very few "best practice" things around ... so, you make up your own best practice. I'm glad to see things evolve.

--- End quote ---
Marco + me equals 110+ years with 75+years in programming.. (sorry Marco, I get the balance 8-) )

--- Quote ---Most of the time, I think you'll find that my questions are actually meant to ask people who have more knowledge of FP than I what "Best practice" (in a FP context) is. That, at least, is my only intention.

--- End quote ---
Best practice is using the new language features too.... These were not added for dinosaurs..

--- Quote ---If I stepped on someone's toes, then I apologize.

--- End quote ---
You didn't. Actually Marco fixed one of the issues. This one is not going to happen. 8-) (I guess)

Navigation

[0] Message Index

[#] Next page

Go to full version