Microsoft MVP성태의 닷넷 이야기
Windows: 266. Windows - 대소문자 구분이 가능한 파일 시스템 [링크 복사], [링크+제목 복사],
조회: 6421
글쓴 사람
정성태 (kevin at jennifersoft.com)
홈페이지
첨부 파일
 
(연관된 글이 1개 있습니다.)

Windows - 대소문자 구분이 가능한 파일 시스템

일례로, WSL 환경에서 대소문자 구분이 있는 파일을 윈도우로 복사하면,

$ pwd
/tmp/testdir
$ echo test > test.txt
$ echo Test > Test.txt
$ cp -r . /mnt/c/temp/testdir
cp: cannot create regular file '/mnt/c/temp/testdir/Test.txt': File exists

첫 번째 test.txt 파일은 복사가 되지만, 두 번째 Test.txt 파일은 복사가 되지 않습니다. 잘 아시는 것처럼, 윈도우의 파일 시스템은 대소문자를 구분하지 않기 때문입니다.

이게 딱히 그동안 문제가 되지는 않았는데, 위에서 설명한 사례처럼 WSL과의 연동이 되다 보니 문제로 부각된 것 같습니다. 그리고, 이런 문제로 인해 윈도우도 디렉터리에 대소문자를 구분할 수 있는 설정을 지원하게 되었습니다.

// Windows 10, build 17107 이후부터 지원

Adjust case sensitivity
; https://learn.microsoft.com/en-us/windows/wsl/case-sensitivity

The Windows file system supports setting case sensitivity with attribute flags per directory.


그래서 다음과 같은 명령어로 특정 디렉터리에 한해 대소문자 구분을 가능하게 합니다.

fsutil.exe file setCaseSensitiveInfo <path>

결국 위에서 문제가 됐던 상황이라면 이렇게 해결할 수 있습니다.

// 현재는 대소문자 구분이 안 되지만,
c:\temp> fsutil.exe file queryCaseSensitiveInfo c:\temp\testdir
Case sensitive attribute on directory c:\temp\testdir is disabled.

// 대소문자 구분하도록 설정 (변경은 관리자 권한만 가능)
c:\temp> fsutil.exe file setCaseSensitiveInfo c:\temp\testdir
Case sensitive attribute on directory c:\temp\testdir is enabled.

// 다시 대소문자 구분 없음으로 변경하려면 disable 옵션만 추가
c:\temp> fsutil.exe file setCaseSensitiveInfo c:\temp\testdir disable

이후 다시 복사를 해보면,

$ cp -r . /mnt/c/temp/testdir

test.txt와 Test.txt 파일이 모두 복사됩니다.

c:\temp\testdir> dir /b
Test.txt
test.txt

c:\temp\testdir> type Test.txt
Test

c:\temp\testdir> type test.txt
test




이렇게 대소문자 구분이 되는 경우, 당연히 프로그램 측에서도 대소문자를 잘 구분해야 합니다. 가령, C#에서 위의 파일을 접근하는 경우,

internal class Program
{
    static void Main(string[] args)
    {
        Console.WriteLine(File.ReadAllText(@"C:\temp\testdir\Test.txt")); // OK
        Console.WriteLine(File.ReadAllText(@"C:\temp\testdir\test.txt")); // OK

        Console.WriteLine(File.ReadAllText(@"C:\temp\testdir\tEst.txt")); // Unhandled exception. System.IO.FileNotFoundException: Could not find file 'C:\temp\testdir\tEst.txt'.
    }
}

해당 디렉터리에 대해 정확히 대소문자를 지정해야만 파일이 열리므로 주의해야 합니다.




[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]

[연관 글]






[최초 등록일: ]
[최종 수정일: 10/26/2024]

Creative Commons License
이 저작물은 크리에이티브 커먼즈 코리아 저작자표시-비영리-변경금지 2.0 대한민국 라이센스에 따라 이용하실 수 있습니다.
by SeongTae Jeong, mailto:techsharer at outlook.com

비밀번호

댓글 작성자
 




... [181]  182  183  184  185  186  187  188  189  190  191  192  193  194  195  ...
NoWriterDateCnt.TitleFile(s)
492정성태5/23/200726596.NET Framework: 89. ManagedThreadId - 두 번째 이야기 [5]파일 다운로드1
491정성태5/21/200726713.NET Framework: 88. ManagedThreadId ? [4]
490정성태5/19/200735212오류 유형: 33. error MSB6003: SxS DLL 로딩 오류 [2]
489정성태5/14/200723045.NET Framework: 87. .NET 2.0에서 C# 3.0 기능 사용하기
488정성태5/14/200721600Windows: 25. Multiple Input Queues
487정성태4/24/200727206VC++: 32. VC++에서 bool이 가지는 의미 [3]
486정성태3/22/200726233Windows: 24. DreamScene과 DWM(Desktop Window Manager)의 관계 [1]
485정성태3/17/200721537오류 유형: 32. VS.NET 2005 - x64 환경에서의 mixed 디버깅 환경 구성
484정성태3/17/200720722오류 유형: 31. SQL Compact Edition 설치 후 오류
483정성태3/17/200742125오류 유형: 30. x64 환경: .NET + COM 프로젝트 실행 시 오류 - 80040154 [2]
482정성태3/17/200731622Team Foundation Server: 17. 팀 프로젝트 접속 및 사용
481정성태3/17/200725536Team Foundation Server: 16. 팀 프로젝트 읽기 전용 사용자 등록
480정성태3/14/200723740.NET Framework: 86. GC(Garbage Collector)의 변화
479정성태3/14/200727602개발 환경 구성: 25. D820 - ReadyBoost 구동
478정성태3/14/200727068개발 환경 구성: 24. D820 고주파음 문제
477정성태3/14/200736346개발 환경 구성: 23. 비스타 x64 버전에서 서명되지 않은 드라이버 사용 [4]
476정성태3/9/200731799개발 환경 구성: 22. D820 노트북 - 설치 및 BitLocker 구성 [1]
475정성태3/6/200726183.NET Framework: 85. 공용 프로퍼티 자동 생성
474정성태3/5/200724413.NET Framework: 84. Lambda 표현식 응용 사례 [1]
473정성태3/4/200731479디버깅 기술: 14. TFS 오류 추적(TF53010, TF14105)
472정성태3/3/200730712디버깅 기술: 13. 예외 발생 시 Minidump 생성 - WinDBG [3]파일 다운로드1
471정성태3/1/200719735디버깅 기술: 12. Managed Method에 Break Point 걸기
469정성태2/28/200731350디버깅 기술: 11. (Managed) Main Method에 Break Point 걸기 [3]파일 다운로드1
470정성태3/1/200722786    답변글 디버깅 기술: 11.1. (Managed) Main Method에 Break Point 걸기 - 내용 보강
468정성태2/25/200732503COM 개체 관련: 20. 탭 브라우저의 윈도우 핸들 구하기 [3]
466정성태2/22/200724320Windows: 23. 롱혼 서버 코어 버전 [2]
... [181]  182  183  184  185  186  187  188  189  190  191  192  193  194  195  ...