Recent

Author Topic: Lock a folder  (Read 417 times)

Hansvb

  • Sr. Member
  • ****
  • Posts: 347
Lock a folder
« on: June 15, 2019, 12:33:50 pm »
Hi, is it possible to lock a folder so that only my own application has free access to the folder content?


lucamar

  • Hero Member
  • *****
  • Posts: 2082
Re: Lock a folder
« Reply #1 on: June 15, 2019, 12:38:35 pm »
Depends on the OS but usually you have to create a "user", make it the folder's owner and prohibit access to everyone else, which means that to access that folder the application must impersonate that user.

Very basically, the same process that allows a web server (and none else) to access its "documents" folder.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

Hansvb

  • Sr. Member
  • ****
  • Posts: 347
Re: Lock a folder
« Reply #2 on: June 15, 2019, 02:12:21 pm »
It is on windows. I found this:
https://www.freepascal.org/docs-html/rtl/dos/fileattributes.html

I think that is a possible solution.

lucamar

  • Hero Member
  • *****
  • Posts: 2082
Re: Lock a folder
« Reply #3 on: June 15, 2019, 05:55:10 pm »
It is on windows. I found this:
https://www.freepascal.org/docs-html/rtl/dos/fileattributes.html

I think that is a possible solution.

No, it isn't. Any application can access any file/folder no matter what (standard) attributes you set. Making it have System and/or Hidden attributes just make it a little harder for very naive programs/users (say, absolute beginners).

What you need for Windows, IIRC, is to change the security attributes of the folder, which is another kettle of fish.
Turbo Pascal 3 CP/M - Amstrad PCW 8256 (512 KB !!!) :P
Lazarus 2.0.2/2.0.4  - FPC 3.0.4 on:
(K|L)Ubuntu 12..16, Windows XP SP3, various DOSes.

Thaddy

  • Hero Member
  • *****
  • Posts: 9187
Re: Lock a folder
« Reply #4 on: June 15, 2019, 06:56:48 pm »
Correct.
also related to equus asinus.