Changeset 7c2a3c7 in mainline for uspace/app/cmpdirs/cmpdirs.c
- Timestamp:
- 2026-03-17T12:37:05Z (31 hours ago)
- Children:
- df4f7c30
- Parents:
- 4a998bf9
- git-author:
- Vít Skalický <skalicky@…> (2026-03-16 13:48:05)
- git-committer:
- Vít Skalický <skalicky@…> (2026-03-17 12:37:05)
- File:
-
- 1 edited
-
uspace/app/cmpdirs/cmpdirs.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/cmpdirs/cmpdirs.c
r4a998bf9 r7c2a3c7 54 54 #define NAME_BUFFER_SIZE 256 55 55 56 // Macros to make handling error less clumbersome56 // Macros to make handling errors less cumbersome 57 57 #define _check_ok(rc, action, ...) if ((rc) != EOK) {fprintf(stderr, __VA_ARGS__); log_msg(LOG_DEFAULT, LVL_ERROR, __VA_ARGS__ ); action; } 58 /** Print message (given by the variable arguments) to log and stderr if rc != EOK and then goto the specified label. */ 58 59 #define check_ok(rc, label, ...) _check_ok(rc, goto label, __VA_ARGS__) 60 /** Print message (given by the variable arguments) to log and stderr if rc != EOK and then break. */ 59 61 #define check_ok_break(rc, ...) _check_ok(rc, break, __VA_ARGS__) 60 62 … … 139 141 } 140 142 143 /** Handles of 2 files or directories to compare */ 141 144 struct entry { 142 145 int handle1; … … 156 159 size_t STACK_INIT_CAPACITY = 256; 157 160 158 /** Create a new growable stack. Don't forget to free it in the end using stack_free*/161 /** Create a new growable stack. Don't forget to free it using stack_free when you are done using it. */ 159 162 static errno_t stack_new(struct stack* s) { 160 163 s->size = 0; … … 201 204 } 202 205 203 /** Returns the last entry in the stack and removes it from it. Does not free any memory */206 /** Returns the last entry in the stack and removes it from it. Does not free any memory. */ 204 207 static errno_t stack_pop(struct stack *s, struct entry *entry_out) { 205 208 if (s->size == 0) { … … 231 234 } 232 235 233 /** Compares the conte tnof 2 files. It assumes:236 /** Compares the content of 2 files. It assumes: 234 237 * - both handles represent a file, not dir 235 238 * - both files have the same size 236 239 * - both buffers are the size CHUNK_SIZE 237 * - both handle are open for reading */240 * - both handles are open for reading */ 238 241 static errno_t content_equal(int handle1, vfs_stat_t stat1, char* buffer1, int handle2, vfs_stat_t stat2, char* buffer2, bool *equal_out) { 239 242 errno_t rc = EOK; … … 265 268 } 266 269 267 /** Checks if the directory/file tree of both handles is equal -- checks presence of files/dirs, content of all files, and metadata. */268 270 static errno_t trees_equal(int root_handle1, int root_handle2, bool* equal_out) { 269 // todo don't forget to check put/close all file handles271 // todo Check once again that all file handles are put at the end 270 272 // Performs a depth-first search on handle1 and compares it to handle2. 271 273 errno_t rc = EOK; … … 289 291 290 292 char name_buffer[NAME_BUFFER_SIZE]; 291 292 // no need to add the initial entry into stack - it's the initial value in the for cycle293 // rc = stack_append(&s, (struct entry){handle1, handle2});294 // if (rc != EOK) goto close3;295 293 296 294 // While there is something in the stack
Note:
See TracChangeset
for help on using the changeset viewer.
