Deleting READ ONLY Files - OS2

This is a discussion on Deleting READ ONLY Files - OS2 ; In order to delete a file with the READONLY bit set according to the doc, first the READONLY atribute has to be reset with DosSetFileInfo(..) This however requires a file handle which is obtained using DosOpen(..) Now we start the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Deleting READ ONLY Files

  1. Deleting READ ONLY Files

    In order to delete a file with the READONLY bit set according to the doc,
    first the READONLY atribute has to be reset with DosSetFileInfo(..)

    This however requires a file handle which is obtained using DosOpen(..)

    Now we start the chicken & egg situation in which in order to use
    DosSetFileInfo(..) we need write access!
    Opening a file with DosOpen(..) with OPEN_ACCESS_WRITEONLY or
    OPEN_ACCESS_READWRITE
    fails with return code 5 ( Access denied) since the file has the READ ONLY
    attribute set.

    So can anyone tell me how I would program to delete a READ ONLY file

    Keith Merrington



  2. Re: Deleting READ ONLY Files

    On Wed, 8 Aug 2007 08:57:18 UTC, "Keith Merrington"
    wrote:

    > In order to delete a file with the READONLY bit set according to the doc,
    > first the READONLY atribute has to be reset with DosSetFileInfo(..)
    >
    > This however requires a file handle which is obtained using DosOpen(..)


    Yes - but DosSetPathInfo() does exactly the same but does not require
    a file hande but istead the same path DosOpen() needs.

    > Now we start the chicken & egg situation in which in order to use
    > DosSetFileInfo(..) we need write access!
    > Opening a file with DosOpen(..) with OPEN_ACCESS_WRITEONLY or
    > OPEN_ACCESS_READWRITE
    > fails with return code 5 ( Access denied) since the file has the READ ONLY
    > attribute set.
    >
    > So can anyone tell me how I would program to delete a READ ONLY file


    DosQueryPathInfo(), modify the info for your needs then
    DosSetPathInfo() followed by DosDelete()

    Anyway you should check each API for success.

    --
    Tschau/Bye
    Herbert

    Visit http://www.ecomstation.de the home of german eComStation
    eComStation 1.2R Deutsch ist da!

  3. Re: Deleting READ ONLY Files

    In , on 08/08/2007
    at 10:57 AM, "Keith Merrington"
    said:

    Hi,

    >In order to delete a file with the READONLY bit set according to the doc,
    >first the READONLY atribute has to be reset with DosSetFileInfo(..)


    >This however requires a file handle which is obtained using DosOpen(..)


    You need to use DosSetPathInfo and work by name.

    Steven

    --
    --------------------------------------------------------------------------------------------
    Steven Levine MR2/ICE 3.00 beta 08pre #10183
    eCS/Warp/DIY/14.103a_W4 www.scoug.com irc.ca.webbnet.info #scoug (Wed 7pm PST)
    --------------------------------------------------------------------------------------------


+ Reply to Thread