A Challenge for Lazarus Gurus
IntroductionI’ve had occasion recently to think about the file system that underlies Lazarus and FPC. I’m transferring some utility code to Lazarus that has its roots in older (some mainframe, some more recent) environments, and I’m running into some conceptual and philosophical issues. This forum is populated by people who have vast amounts of collective knowledge, and it occurred to me to pose a challenge (in the hopes that it might provoke people to dump some data that they might not otherwise think to share).
So here it is! A problem statement and series of questions. The original document is uploaded so you can read it off-line if you wish.
Good luck, and thankyou in advance!
StatementYou are given a value ( an integer of some size) which, you are told, represents your “gateway to a file”.
This integer value may be passed to previously compiled code in order to make changes to, or retrieve information from, the file. This includes meta-information (ie information about the file, rather than information contained within the file).
QuestionsYou get to specify the size (in bits) of the integer, and (if necessary) whether it is signed or insigned.
1. What are the possible semantics of the integer value? i.e. What does the integer represent? What other areas of memory might be involved with the value?
2. What Lazarus (or FPC) facilities use this definition of ‘gateway to a file’?
3. What Lazarus (or FPC) facilities can not be used with this definition of ‘gateway to a file’?
4. What additional information do you need to answer any of these questions?
5. Imagine yourself to be a piece of code that has nothing but this integer value. Thinking about your answer to questions 3 and 4, how would you determine:
5.1. The name of the file
5.2. The type of the file
5.3. The security constraints of the file
5.4. How the file was opened
5.5. The location, on disk, of the start of the file
5.6. The size of the file in bytes
5.7. The size of the file in sectors (or any other disc allocation unit you may care to use)