mirror of
https://github.com/xfarrow/dircomp.git
synced 2025-06-05 21:49:19 +02:00
Updated Mathematical correctness of dircomp (markdown)
@@ -37,4 +37,4 @@ As explained in (**1**), it is checked if each element (including folders) with
|
||||
While looping over the elements of the first directory, if a folder is found and if one with the same name exists in the second directory, `analyze_directories()` will be called again on said folders, generating a recursion. It is guaranteed that the recursion will terminate because it will eventually be reached a leaf of the File System (no subfolders). The result of this recursive call will be put in `and` with the current value of `is_directory_equal` and its result assigned to `is_directory_equal`. This is done because if two subdirectories are not equivalent, then the root directories will not be equal (hence, `false and anything = false`), but if said subdirectories are equivalent, then the overall result depends on the current result of `is_directory_equal` (and potentially of the parent recursive calls) (hence, `true and anything = [depends on the 'anything']`).
|
||||
|
||||
### Conclusion
|
||||
Since nowhere else is the 'is_directory_equal' variable set to true except in its definition, if it will be ever set to false in one of these four cases, then the directories will not be equivalent since this is the variable that the function returns. Instead, if the flow of execution never hits these points, 'is_directory_equal' will keep being true, which will be the value returned to the calling function.
|
||||
Since nowhere else is the `is_directory_equal` variable set to true except in its definition, if it will be ever set to false in one of these four cases, then the directories will not be equivalent since this is the variable that the function returns. Instead, if the flow of execution never hits these points, `is_directory_equal` will keep being true, which will be the value returned to the calling function.
|
||||
|
Reference in New Issue
Block a user