Recent

Author Topic: Lock a folder  (Read 1353 times)

Hansvb

  • Hero Member
  • *****
  • Posts: 618
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: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Hansvb

  • Hero Member
  • *****
  • Posts: 618
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: 4219
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/FPC 2.0.8/3.0.4 & 2.0.12/3.2.0 - 32/64 bits on:
(K|L|X)Ubuntu 12..18, Windows XP, 7, 10 and various DOSes.

Thaddy

  • Hero Member
  • *****
  • Posts: 14373
  • Sensorship about opinions does not belong here.
Re: Lock a folder
« Reply #4 on: June 15, 2019, 06:56:48 pm »
Correct.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

 

TinyPortal © 2005-2018