--- "Arkady V.Belousov" <[EMAIL PROTECTED]> escribió:
> Hi!
>
> 24-á×Ç-2006 23:42 [EMAIL PROTECTED] (Diego Rodriguez) wrote to
> freedos-devel
> <[email protected]>:
>
> DR> Turbo C chmod function fails under FreeDOS when you try to change
> DR> permissions of a directory, e.g.
> DR> chmod (path, S_IREAD|S_IWRITE) fails and return -1, but it works
> under
> DR> DR DOS.
>
> This, probably, feature of DR-DOS, but under MS-DOS and FreeDOS
> you
> can't sett attributes of directory without clearing DIRECTORY bit.
> See RBIL:
>
> ______________O\_/_________________________________\_/O______________
> Notes: will not change volume label or directory attribute bits, but
> will
> change the other attribute bits of a directory (the
> directory
> bit must be cleared to successfully change the other
> attributes of a
> directory, but the directory will not be changed to a
> normal file as
> a result)
> _____________________________________________________________________
> O/~\ /~\O
>
> Borland's chmod() is implemented so (slightly changed source from BC
> RTL):
>
> ______________O\_/_________________________________\_/O______________
> int chmod (const char *name, int permiss) {
> int attrib = _chmod (name, 0);
> if (attrib == -1) return -1;
> attrib &= ~FA_RDONLY;
> if ((permiss & S_IWRITE) == 0) attrib |= FA_RDONLY;
> if (_chmod (name, 1, attrib) == -1)
> return -1;
> return 0;
> }
> _____________________________________________________________________
> O/~\ /~\O
>
> Thus, unfortunately, Borland's chmod() is inapplicable for
> directories, so
> use _chmod() or _dos_setfileattr() directly. For example:
>
> ______________O\_/_________________________________\_/O______________
> #include <stdio.h>
> #include <dos.h>
> #include <io.h>
> #include <errno.h>
> int main (void) {
> int attrib = _chmod ("TEST", 0);
> if (attrib == -1) return printf ("error: _chmod(0) (errno: %u)\n",
> errno);
> attrib &= ~FA_RDONLY;
> if (_chmod ("TEST", 1, attrib & ~_A_SUBDIR) == -1)
> /*------------------------------^^^^^^^^^^^^*/
> return printf ("error: _chmod(1) (errno: %u)\n", errno);
> return printf ("Ok.\n");
> }
> _____________________________________________________________________
> O/~\ /~\O
>
>
Thanks for your help, it worked. I didn't know that DR-DOS has so many
diffs. with M$/FreeDOS.
______________________________________________
LLama Gratis a cualquier PC del Mundo.
Llamadas a fijos y móviles desde 1 céntimo por minuto.
http://es.voice.yahoo.com
-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Freedos-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freedos-devel