PDA

View Full Version : differentiate cause



NewsArchive
05-07-2011, 06:12 AM
Hi Friedrich,

sometimes, in very rare circumstances, the new move file function does
not move all files, which a covered by a given wild card pattern.
Perhaps anti virus products cause this. I think, it's something, we
can't control.

So I have a few related questions:

1.) If zero files are moved, how can I differentiate, whether it was not
possible to move any file or there was no file to move?

2.) If SB_ERRORCODE is zero (error occured), how can I get the reason?

3.) If your internal call of the WIN API function returns normal
(without error), could you add an additional check, that there are no
files left which match the wildcard pattern and if there are still files
left, try to move them in a second attempt?

Thanks for your answer.

Markus

NewsArchive
05-07-2011, 06:12 AM
Hi Markus,

One idea we have is to give access (not only in this function) to the
GetLastError value that most Windows API function return in case of a failed
operation. Then you can see why the function did not succeed. We are
already experimenting with this in SB8.

BTW, if the MoveFile function fails then it terminates immediately. No
additional check is possible.

Friedrich

NewsArchive
05-07-2011, 06:13 AM
Hi Friedrich,

> One idea we have is to give access (not only in this function) to the
> GetLastError value

would this solve my first AND my second question?

Markus

NewsArchive
05-07-2011, 06:13 AM
>
> would this solve my first AND my second question?
>

I would say, yes.

Let us assume, zero files are moved because no files matched the wildcard.

Then %_SB_ERRORCODE% is 0 (failed operation) and %_SB_RETURNEX% is 0 (no
files moved) and %_SB_GETLASTERROR% is 0 (no move file error detected).

Let us assume, zero files are moved, one file matched that wildcard but it
could not be moved (e.g. locked file scenario).

Then %_SB_ERRORCODE% is 0 (failed operation) and %_SB_RETURNEX% is 0 (no
files moved) and %_SB_GETLASTERROR% is ERROR_ACCESS_DENIED (move file error
detected).

Friedrich

NewsArchive
05-07-2011, 06:13 AM
OK.

So it would be nice, if the function would return Win_Last_error in
_SB_RETURNEX like "Run Program" does.

Or an additional System Varibale %_SB_WIN_LAST_ERROR%

Markus

NewsArchive
05-07-2011, 06:13 AM
Markus,

> So it would be nice, if the function would return Win_Last_error in
> _SB_RETURNEX like "Run Program" does.
>
> Or an additional System Varibale %_SB_WIN_LAST_ERROR%

The %_SB_RETURNEX% variable holds the number of copied files in the "Move
File(s)..." function.

In SB8, %_SB_GETLASTERROR% holds the last GetLastError return value.

Friedrich