Search code examples
delphiwindows-7attributesdelphi-xe8

Delphi debug output folder attributes


I am trying to figure out how I can set the default attributes on the folders that delphi created when it builds a project. All my googling has provided no answer.

For example:

Say I have a delphi project at C:\MyProject\myProject.dpr. When I build this project, Delphi will create C:\MyProject\Win32\Debug\ folders. The Win32\Debug\ folders comes from Tools - Options - Environment Options - Delphi Options - Debug DCU Path.

The Problem is the Debug folder delphi created has the Read-Only attribute checked. With that folder being Read-Only, I get frequent build errors, like:

[fatal error] could not create output file C:\MyProject\myProject.exe

If I manually uncheck the Read-Only attribute I can build my project fine.

So does anyone on SO know how to tell Delphi to create this folder without being Read-Only?

(I am using Delphi XE8 but I believe this applies to all versions and Windows 7 Professional)


Solution

  • The folders are created with a call to CreateDirectory that passes NULL as the lpSecurityAttributes parameter. As documented this means that:

    If lpSecurityAttributes is NULL, the directory gets a default security descriptor. The ACLs in the default security descriptor for a directory are inherited from its parent directory.

    In other words the security settings are inherited from the parent. You can make this directory writeable by making its parent writeable.