Skip to content

Commit

Permalink
[Mac] Fix path encoding problem in wt-monitor.
Browse files Browse the repository at this point in the history
  • Loading branch information
killing committed Dec 2, 2014
1 parent b48c404 commit 77482e0
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions daemon/wt-monitor-macos.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,16 @@ process_one_event (const char* eventPath,
{
WTStatus *status = info->status;
char *filename;
char *event_path_nfc;
const char *tmp;
tmp = eventPath + strlen(worktree);

event_path_nfc = g_utf8_normalize (eventPath, -1, G_NORMALIZE_NFC);

tmp = event_path_nfc + strlen(worktree);
if (*tmp == '/')
tmp++;
filename = g_strdup(tmp);
g_free (event_path_nfc);

/* Reinterpreted RENAMED as combine of CREATED or DELETED event */
if (eventFlags & kFSEventStreamEventFlagItemRenamed) {
Expand Down Expand Up @@ -194,9 +199,12 @@ add_watch (SeafWTMonitor *monitor, const char* repo_id, const char* worktree)
RepoWatchInfo *info;
double latency = 0.25; /* unit: second */

char *worktree_nfd = g_utf8_normalize (worktree, -1, G_NORMALIZE_NFD);

CFStringRef mypaths[1];
mypaths[0] = CFStringCreateWithCString (kCFAllocatorDefault,
worktree, kCFStringEncodingUTF8);
worktree_nfd, kCFStringEncodingUTF8);
g_free (worktree_nfd);
CFArrayRef pathsToWatch = CFArrayCreate(NULL, (const void **)mypaths, 1, NULL);
FSEventStreamRef stream;

Expand Down

0 comments on commit 77482e0

Please sign in to comment.