- const size_t path_len = strlen(path);
- const size_t sidecar_ext_len = strlen(BINARY_SIDECAR_EXT); // this can be optimized
- const size_t sidecar_path_len = path_len + sidecar_ext_len + 1;
- char *sidecar_path = (char *) malloc(sidecar_path_len);
- memset(sidecar_path, '\0', sidecar_path_len);
- memcpy(sidecar_path, path, path_len);
- memcpy(sidecar_path + path_len, BINARY_SIDECAR_EXT, sidecar_ext_len);
-
- return sidecar_path;
+#define CFG xattrs_config
+ if ( strncmp( path, CFG.source_dir, CFG.source_dir_size ) == 0 ) {
+ const char *p = path + CFG.source_dir_size;
+ if ( CFG.sidecar_dir ) {
+ return strjoin( CFG.sidecar_dir, p, BINARY_SIDECAR_EXT, 0 );
+ }
+ }
+ return strjoin( path, BINARY_SIDECAR_EXT, 0 );
+#undef CFG