octave mkdir fails after recursive rmdir -


i have code creates subfolder first removes subfolder if existed. using octave3.6.4_gcc4.6.2 mingw on win7 pro machine. noticed mkdir fails if subfolder existed , contained several files. seems rmdir has not completed in background before next lines of code executed. below sample of test code.

parentdir = 'c:\temp\rmdir'; childdir = fullfile(parentdir, 'output'); if (exist(childdir, 'dir') ~= 0)     [status] = rmdir(childdir, 's');     disp(status); end; [status] = mkdir(parentdir, 'output'); disp(status); disp(exist(childdir, 'dir')); 

below octave result when subfolder not exist. works expected.

octave:5> testrmdir   1   7 

below octave result when subfolder exists , empty. works expected.

octave:6> testrmdir   1   1   7 

below octave result when subfolder exists , contains 3 png files total size of 349 kb. status 1 both mkdir , rmdir. however, exist function reports folder not exist. confirm windows explorer subfolder deleted. guess when mkdir executes, files still being deleted prior rmdir function. mkdir reports success because subfolder has not been deleted rmdir yet. however, time exist executed rmdir has completed , subfolder no longer exists.

octave:7> testrmdir   1   1   0 

i tried different file types following results:

  • 2 png files, 232 kb total - pass
  • 4 png files, 465 kb total - fail
  • 3 png files, 349 kb total - fail
  • 3 csv files, 518 kb total - pass
  • 5 csv files, 777 kb total - fail

the behavior same when run octave command line. have used same code on matlab in past without noticeable issues. now, had switch octave test automation on different machine.

does make sense? suggestions on how make code work regardless of subfolder contents or size?

not sure if important, have following setting in resource file: confirm_recursive_rmdir(false).

i changed if statement while loop , fixed problem (i.e. did replace "if" "while"). added counter in while loop , saw rmdir successful on first iteration. therefore, cannot explain why code not work if statement. see expanded code new counter below. said, code works if replace "if" in original code "while".

parentdir = 'c:\temp\rmdir'; childdir = fullfile(parentdir, 'output'); count = 0; while (exist(childdir, 'dir') ~= 0) %if (exist(childdir, 'dir') ~= 0)     count++     [status] = rmdir(childdir, 's');     disp(status);     disp(count); end; [status] = mkdir(parentdir, 'output'); disp(status); disp(exist(childdir, 'dir')); 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -