Article View: borland.public.cppbuilder.nativeapi
Article #11292Re: how to determine the permissions of a folder using XP
From: Thomas Maeder [TeamB]
Date: Tue, 17 Feb 2004 18:46
Date: Tue, 17 Feb 2004 18:46
57 lines
2876 bytes
2876 bytes
"Roland" <neubert@wst-gmbh.de> writes:
> maeder@glue.ch (Thomas Maeder [TeamB]) wrote:
> Thanks Thomas, but no success under XP:
Actually, *you* wrote that. This is a screen I am looking at, not a mirror :-)
> I tested it as follows:
>
> // F:\\ENTWICK\\Roland\\1Projekte\\DDV_TEST\\incoming\\949\dd949_01_2004003.20031230_212909
Is this the contents of strFileName?
> AnsiString sTest = ExtractFileDir(strFileName);
Then sTest would probably be the path of the directory containing the file
named by strFileName.
> struct stat statbuf;
> if (stat(sTest.c_str(),&statbuf)==0)
> {
> if (S_ISDIR(statbuf.st_mode))
> Memo1->Lines->Add(sTest + " is a directory");
> if (statbuf.st_mode&S_IRUSR)
> Memo1->Lines->Add("owner has read permission");
> if (statbuf.st_mode&S_IWUSR)
> Memo1->Lines->Add("owner has write permission");
> if (statbuf.st_mode&S_IXUSR)
> Memo1->Lines->Add("owner has execute permission");
The output you give below indicates that the user who ran the program has
all permissions on the directory ...
> if (chmod(sTest.c_str(),statbuf.st_mode&~S_IXUSR)==0)
> Memo1->Lines->Add("permissions modified");
> else
> Memo1->Lines->Add("chmod failed");
... and is able to lose execute permission.
> }
> else
> Memo1->Lines->Add("stat failed");
>
>
>
> if(RemoveDir(sTest))
All these permissions are not sufficient for removing this directory.
Removing a file system element (directory, file) does not change the element
itself, but the directory *that contains it*. Does the user have the
necessary permissions for that directory?
Technical Details
Message-ID:
<m2ekstsfvi.fsf@madbox2.local>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<402c98a1$1@newsgroups.borland.com> <m2hdxu6gm3.fsf@madbox2.local> <4031d480$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,ce8d67f0062a8486 X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-17 10:54:44 PST Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: how to determine the permissions of a folder using XP References: <402c98a1$1@newsgroups.borland.com> <m2hdxu6gm3.fsf@madbox2.local> <4031d480$1@newsgroups.borland.com> From: maeder@glue.ch (Thomas Maeder [TeamB]) Organization: TeamB Date: Tue, 17 Feb 2004 19:46:57 +0100 Message-ID: <m2ekstsfvi.fsf@madbox2.local> User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux) Cancel-Lock: sha1:bgrlsn5YkAyl3Z+Z/Dy+1Q3mVe4= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 217.162.153.50 X-Trace: newsgroups.borland.com 1077043636 217.162.153.50 (17 Feb 2004 10:47:16 -0800) Lines: 57 X-Authenticated-User: tmaeder Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail