🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #11288

Re: how to determine the permissions of a folder using XP

#11288
From: Roland
Date: Tue, 17 Feb 2004 08:44
76 lines
3221 bytes
maeder@glue.ch (Thomas Maeder [TeamB]) wrote:
Thanks Thomas, but no success under XP:

I tested it as follows:

// F:\\ENTWICK\\Roland\\1Projekte\\DDV_TEST\\incoming\\949\dd949_01_2004003.20031230_212909
        

        AnsiString sTest = ExtractFileDir(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");

          if (chmod(sTest.c_str(),statbuf.st_mode&~S_IXUSR)==0)
            Memo1->Lines->Add("permissions modified");
          else
            Memo1->Lines->Add("chmod failed");
        }
        else
          Memo1->Lines->Add("stat failed");



        if(RemoveDir(sTest))
        {
           Memo1->Lines->Add(strAct_LastFolder + " wurde gel�scht."); //success!
        }
        else
        {
           Memo1->Lines->Add("Konnte  " + strAct_LastFolder + " nicht l�schen."); //unable to delete...

           LPTSTR lpMsgBuf;
           FormatMessage(
              FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
              NULL,
              GetLastError(),
              MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
              (LPTSTR) &lpMsgBuf,
              0,
              NULL
              );
              // Display the string.
              Application->MessageBox(  lpMsgBuf, "Directory l�schen...", MB_OK|MB_ICONINFORMATION );
              // Free the buffer.
              LocalFree( lpMsgBuf );

        }

/*
Result at Memo1:

F:\ENTWICK\Roland\1Projekte\DDV_TEST\incoming\949\dd949_01_2004003.20031230_212909 is a directory
owner has read permission
owner has write permission
owner has execute permission
permissions modified
Konnte  dd949_01_2004003.20031230_212909\ nicht l�schen. 


GetLastError tells: "Zugriff verweigert" - "Access denied."

*/


Best regards
Roland
Technical Details
Message-ID: <4031d480$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <402c98a1$1@newsgroups.borland.com> <m2hdxu6gm3.fsf@madbox2.local>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,ce8d67f0062a8486
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2004-02-17 01:09:44 PST
From: "Roland" <neubert@wst-gmbh.de>
Sender: "Roland" <neubert@wst-gmbh.de>
Reply-To: "Roland" <neubert@wst-gmbh.de>
Subject: Re: how to determine the permissions of a folder using XP
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 62.180.198.47     
References: <402c98a1$1@newsgroups.borland.com> <m2hdxu6gm3.fsf@madbox2.local>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <4031d480$1@newsgroups.borland.com>
Date: 17 Feb 2004 00:44:48 -0800
X-Trace: newsgroups.borland.com 1077007488 207.105.83.66 (17 Feb 2004 00:44:48 -0800)
Lines: 76
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail