🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#11335
From: Thomas Maeder [TeamB]
Date: Fri, 13 Feb 2004 17:20
40 lines
2348 bytes
"Roland" <neubert@wst-gmbh.de> writes:

> on Win XP I have the problem, that I get no permission to delete an empty
> folder using the RemoveDir function. Does anyone know how to determine and
> change the permissions of a folder created by another progam?

For determining permissions, you can use the POSIX Standard function stat().
For changing permissions, you can use the POSIX Standrad function chmod().

#include <sys/types.h>
#include <sys/stat.h>
#include <io.h>

#include <iostream>
#include <ostream>
#include <cstring>
#include <cerrno>

int main()
{
  struct stat statbuf;
  if (stat("C:\\Temp\\x",&statbuf)==0)
  {
    if (S_ISDIR(statbuf.st_mode))
      std::cout << "C:\\Temp\\x is a directory\n";
    if (statbuf.st_mode&S_IRUSR)
      std::cout << "owner has read permission\n";
    if (statbuf.st_mode&S_IWUSR)
      std::cout << "owner has write permission\n";
    if (statbuf.st_mode&S_IXUSR)
      std::cout << "owner has execute permission\n";

    if (chmod("C:\\Temp\\x",statbuf.st_mode&~S_IXUSR)==0)
      ; // permissions modified
    else
      std::perror("chmod failed");
  }
  else
    std::perror("stat failed");
}
Technical Details
Message-ID: <m2hdxu6gm3.fsf@madbox2.local>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer00.lnd.ops.eu.uu.net!bnewsoutpeer00.bru.ops.eu.uu.net!bnewsinpeer01.bru.ops.eu.uu.net!emea.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <402c98a1$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-13 09:35:28 PST
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: how to determine the permissions of a folder using XP
References: <402c98a1$1@newsgroups.borland.com>
From: maeder@glue.ch (Thomas Maeder [TeamB])
Organization: TeamB
Date: Fri, 13 Feb 2004 18:20:36 +0100
Message-ID: <m2hdxu6gm3.fsf@madbox2.local>
User-Agent: Gnus/5.1002 (Gnus v5.10.2) XEmacs/21.4 (Rational FORTRAN, linux)
Cancel-Lock: sha1:Z6iRgbixempd6YmAUariCQQicIs=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Host: 217.162.153.50
X-Trace: newsgroups.borland.com 1076692854 217.162.153.50 (13 Feb 2004 09:20:54 -0800)
Lines: 40
X-Authenticated-User: tmaeder
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.tele.dk!news.tele.dk!small.news.tele.dk!lnewsoutpeer00.lnd.ops.eu.uu.net!lnewsinpeer00.lnd.ops.eu.uu.net!bnewsoutpeer00.bru.ops.eu.uu.net!bnewsinpeer01.bru.ops.eu.uu.net!emea.uu.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail