On 20/10/2007, Stephan Rose kermos@somrek.net wrote:
On that note, I noticed that ReplaceFileW still isn't implemented as it's not possible to safe a profile under Supreme Commander. Wasn't there a patch for this? I distinctly remember that because I was going to implement that function until I saw someone else had already submitted a patch with an implementation. What happened with that?
The patch was rejected by Alexandre because the patch was implementing that command using Windows API calls, when it should be implemented natively as POSIX/GNU calls.
Feel free to implement that function. The best way to get it accepted is to have another patch that provides a set of corresponding tests, so the behaviour can be checked against Windows. This then ensures that the API is doing the correct thing.
Test cases worth covering are: * using NULL values in all permutations of source, target and backup file; * covering all premutations of file existing and not existing for the source, target and backup file; * how the replace flags affect the behaviour; * caller not having write access to the file being replaced; * different ACL combinations on the source file.
Things worth testing for: * return value from the function; * GetLastError status; * file content of source, target and backup files (and presence thereof); * preservation of the attributes the API says are preserved (creation time, DACLs, etc).
This is a lot to cover, but a simplified implementation with a basic set of tests that cover at least: * using NULL values in all permutations of source, target and backup file; * covering all premutations of file existing and not existing for the source, target and backup file; and checks at least: * return value from the function; * GetLastError status; * file content of source, target and backup files (and presence thereof); * a subset (or none) of the attributes being preserved.
There should also be notes covering what functionality is missing.
NOTE: I am not sure all of the above is possible without using Windows API calls, but that is where tests will help convince Alexandre.
- Reece