[vfs] switches file watcher reports encoding to UTF-8 on Windows (IDEA-103559)

This commit is contained in:
Roman Shevchenko
2016-02-10 16:25:16 +01:00
parent 0a871a6d72
commit 80e2a6b401
5 changed files with 14 additions and 11 deletions
Binary file not shown.
Binary file not shown.
+4 -3
View File
@@ -260,9 +260,6 @@ void PrintWatchRootReparsePoints() {
// -- Watcher thread ----------------------------------------------------------
void PrintChangeInfo(char *rootPath, FILE_NOTIFY_INFORMATION *info) {
char FileNameBuffer[_MAX_PATH];
int converted = WideCharToMultiByte(CP_ACP, 0, info->FileName, info->FileNameLength / sizeof(WCHAR), FileNameBuffer, _MAX_PATH - 1, NULL, NULL);
FileNameBuffer[converted] = '\0';
char *command;
if (info->Action == FILE_ACTION_ADDED || info->Action == FILE_ACTION_RENAMED_OLD_NAME) {
command = "CREATE";
@@ -277,6 +274,10 @@ void PrintChangeInfo(char *rootPath, FILE_NOTIFY_INFORMATION *info) {
return; // unknown command
}
char FileNameBuffer[2*_MAX_PATH + 1];
int converted = WideCharToMultiByte(CP_UTF8, 0, info->FileName, info->FileNameLength / sizeof(WCHAR), FileNameBuffer, 2*_MAX_PATH, NULL, NULL);
FileNameBuffer[converted] = '\0';
EnterCriticalSection(&csOutput);
puts(command);
printf("%s", rootPath);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,6 +32,7 @@ import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.ShutDownTracker;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.openapi.vfs.CharsetToolkit;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.openapi.vfs.local.FileWatcherNotificationSink;
@@ -290,7 +291,7 @@ public class NativeFileWatcherImpl extends PluggableFileWatcher {
@SuppressWarnings("IOResourceOpenedButNotSafelyClosed")
private MyProcessHandler(@NotNull Process process, @NotNull String commandLine) {
super(process, commandLine, null); // do not access EncodingManager here
super(process, commandLine, SystemInfo.isWindows ? CharsetToolkit.UTF8_CHARSET : null); // do not access EncodingManager here
myWriter = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()));
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2015 JetBrains s.r.o.
* Copyright 2000-2016 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -53,10 +53,12 @@ import static com.intellij.openapi.util.io.IoTestUtil.*;
@SuppressWarnings("Duplicates")
public class FileWatcherTest extends PlatformTestCase {
private static final Logger LOG = Logger.getInstance(NativeFileWatcherImpl.class);
private static final int INTER_RESPONSE_DELAY = 500; // time to wait for a next event in a sequence
private static final int NATIVE_PROCESS_DELAY = 60000; // time to wait for a native watcher response
private static final Logger LOG = Logger.getInstance(NativeFileWatcherImpl.class);
@SuppressWarnings("SpellCheckingInspection") private static final String UNICODE_NAME = "Юникоде-Úñíçødê.txt";
private FileWatcher myWatcher;
private LocalFileSystem myFileSystem;
@@ -772,14 +774,13 @@ public class FileWatcherTest extends PlatformTestCase {
}
public void testUnicodePaths() throws Exception {
if (!SystemInfo.isUnix || SystemInfo.isMac) {
System.err.println("Ignored: well-defined FS required");
if (SystemInfo.isMac) {
System.err.println("Ignored: not yet supported");
return;
}
File topDir = createTestDir(myTempDirectory, "top");
File testDir = createTestDir(topDir, "тест");
File testFile = createTestFile(testDir, "файл.txt");
File testFile = createTestFile(topDir, UNICODE_NAME);
refresh(topDir);
LocalFileSystem.WatchRequest request = watch(topDir);