Re: neko.FileSystem.deleteDirectory

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: neko.FileSystem.deleteDirectory

Baluta Cristian
Old topic, but does anyone have such a snippet, to recursively delete the directory? Thanks.

On Fri, Jul 25, 2008 at 9:57 PM, Owen Durni <[hidden email]> wrote:
I'm not sure if this is the actual issue, but sometimes this type of
restriction is enforced by the system. Sometimes, to make a recursive
delete function you actually have to write code to delete all of the
contents of a directory before removing the directory itself.

On Fri, Jul 25, 2008 at 2:36 PM, Zárate <[hidden email]> wrote:
> Hi list,
>
> neko.FileSystem.deleteDirectory doesnt delete the directory if it isnt
> empty. Would it be possible to add a forceEvenIfNotEmpty parameter
> (default to false)?
>
> I can implement and do the check myself in HippoHX, just wondering if
> there are other reasons besides the obvious issue of deleting a
> something nested inside that you are not aware of.
>
> Cheers,
>
> Juan
>
> --
> Juan Delgado - Zárate
> http://zarate.tv
> http://dandolachapa.com
> http://loqueyosede.com
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: neko.FileSystem.deleteDirectory

Simon Richardson
check in here[1] - I'm pretty sure Juan solved the recursive delete


On 31 Mar 2011, at 09:10, Baluta Cristian wrote:

Old topic, but does anyone have such a snippet, to recursively delete the directory? Thanks.

On Fri, Jul 25, 2008 at 9:57 PM, Owen Durni <[hidden email]> wrote:
I'm not sure if this is the actual issue, but sometimes this type of
restriction is enforced by the system. Sometimes, to make a recursive
delete function you actually have to write code to delete all of the
contents of a directory before removing the directory itself.

On Fri, Jul 25, 2008 at 2:36 PM, Zárate <[hidden email]> wrote:
> Hi list,
>
> neko.FileSystem.deleteDirectory doesnt delete the directory if it isnt
> empty. Would it be possible to add a forceEvenIfNotEmpty parameter
> (default to false)?
>
> I can implement and do the check myself in HippoHX, just wondering if
> there are other reasons besides the obvious issue of deleting a
> something nested inside that you are not aware of.
>
> Cheers,
>
> Juan
>
> --
> Juan Delgado - Zárate
> http://zarate.tv
> http://dandolachapa.com
> http://loqueyosede.com
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org



--
Băluță Cristian
http://ralcr.com
http://imagin.ro
--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: neko.FileSystem.deleteDirectory

George McBay
In reply to this post by Baluta Cristian
                This is basically what I use (quickly refactored from
a function that does more than just delete a directory so I apologize
if there are any goofs in it)


                 private function
deleteDirectoryRecursive(directoryName:String):Void
                  {
                                   for (item in
FileSystem.readDirectory(directoryName))
                {
                        var path:String = directoryName + '/' + item;
               
                        if (FileSystem.isDirectory(path))
                        {
                                deleteDirectoryRecursive(path);
                        }
                        else
                        {
                                FileSystem.deleteFile(path);
                        }
                }
               
                if (FileSystem.exists(directoryName) && FileSystem.isDirectory(directoryName))
                {
                        FileSystem.deleteDirectory(directoryName);
                }
        }


On Thu, Mar 31, 2011 at 1:10 AM, Baluta Cristian
<[hidden email]> wrote:

> Old topic, but does anyone have such a snippet, to recursively delete the
> directory? Thanks.
>
> On Fri, Jul 25, 2008 at 9:57 PM, Owen Durni <[hidden email]> wrote:
>>
>> I'm not sure if this is the actual issue, but sometimes this type of
>> restriction is enforced by the system. Sometimes, to make a recursive
>> delete function you actually have to write code to delete all of the
>> contents of a directory before removing the directory itself.
>>
>> On Fri, Jul 25, 2008 at 2:36 PM, Zárate <[hidden email]> wrote:
>> > Hi list,
>> >
>> > neko.FileSystem.deleteDirectory doesnt delete the directory if it isnt
>> > empty. Would it be possible to add a forceEvenIfNotEmpty parameter
>> > (default to false)?
>> >
>> > I can implement and do the check myself in HippoHX, just wondering if
>> > there are other reasons besides the obvious issue of deleting a
>> > something nested inside that you are not aware of.
>> >
>> > Cheers,
>> >
>> > Juan
>> >
>> > --
>> > Juan Delgado - Zárate
>> > http://zarate.tv
>> > http://dandolachapa.com
>> > http://loqueyosede.com
>> >
>> > --
>> > haXe - an open source web programming language
>> > http://haxe.org
>> >
>>
>> --
>> haXe - an open source web programming language
>> http://haxe.org
>
>
>
> --
> Băluță Cristian
> http://ralcr.com
> http://imagin.ro
>
> --
> haXe - an open source web programming language
> http://haxe.org
>

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: neko.FileSystem.deleteDirectory

Jens Peter Secher
In reply to this post by Baluta Cristian
On 2011-03-31 10:10, Baluta Cristian wrote:
> Old topic, but does anyone have such a snippet, to recursively delete
> the directory? Thanks.

//
// Recursively delete everything reachable from the path.
// Silently ignores nonexisting paths.
//
public static function unlink( path : String ) : Void
{
  if( neko.FileSystem.exists( path ) )
  {
    if( neko.FileSystem.isDirectory( path ) )
    {
      for( entry in neko.FileSystem.readDirectory( path ) )
      {
        unlink( path + "/" + entry );
      }
      neko.FileSystem.deleteDirectory( path );
    }
    else
    {
      neko.FileSystem.deleteFile( path );
    }
  }
}

--
haXe - an open source web programming language
http://haxe.org