Page 2 of 2

Re: Delete all files but keep subdirectories

Posted: Thu Mar 22, 2018 4:08 pm
by softwarefailure
@broadblues:
Thanks, this works fine from a shell on MorphOS but it doesn't work from a makefile. When doing something like this:

Code: Select all

clean:
    list files LFORMAT "DELETE %s%s" dir1 TO PIPE:mypipe | execute PIPE:mypipe
    list files LFORMAT "DELETE %s%s" dir2 TO PIPE:mypipe | execute PIPE:mypipe
    list files LFORMAT "DELETE %s%s" dir3 TO PIPE:mypipe | execute PIPE:mypipe
Only the first command works. The second and third will fail with "EXECUTE: Can't open PIPE:mypipe. Object is in use".

When executing all three lines from a shell, however, it works fine. Well, I guess I should bug the MorphOS guys about it...

Re: Delete all files but keep subdirectories

Posted: Thu Mar 22, 2018 7:07 pm
by Raziel
The makefile won't be created everytime you build your project, i presume? (and even if, you could probably easily alter the creation of your clean: lines)

So why not do a specific line for every dir you are processing?

Code: Select all

clean:
    list files LFORMAT "DELETE %s%s" dir1 TO PIPE:mypipe | execute PIPE:mypipe
    list files LFORMAT "DELETE %s%s" dir2 TO PIPE:mypipe2 | execute PIPE:mypipe2
    list files LFORMAT "DELETE %s%s" dir3 TO PIPE:mypipe3 | execute PIPE:mypipe3
I'm not using MOS, but it sounds like the pipe you created isn't freed/unlocked after it was executed/used/locked from a makefile/batch script.
That, of course, is a simple guess :-)

Re: Delete all files but keep subdirectories

Posted: Thu Mar 22, 2018 9:42 pm
by softwarefailure
MorphOS team says it's not allowed to use non-ixemul programs in makefiles so I'm now doing

Code: Select all

find dir1 -type f -maxdepth 1 -exec rm -f {} \; 
find dir2 -type f -maxdepth 1 -exec rm -f {} \; 
find dir3 -type f -maxdepth 1 -exec rm -f {} \; 
instead. On OS4 I can probably use the version suggested by broadblues. I still need to check that.