Accurev 저장소를 git 저장소로 변환하려면 ac2git 도구를 사용하고 있습니다. 파이썬 파일에서 os.walk() 함수가 실행될 때 문제가 발생했습니다. 내 프로젝트에 꽤 복잡한 빌드 경로가 있기 때문에 Windows 7에서 경로 길이가 260 제한을 초과하는 파일을 중첩했습니다. microsoft support에서 제공하는 해결 방법을 사용해 보았지만 오류가 해결되지 않았습니다. 나는 여전히 오류가 발생한다. [Winerror 3] : 실제로 존재하지만 길이 제한으로 인해 액세스 할 수없는 경우 파일을 찾을 수 없다. 내가 추가 한파이썬 스크립트가있는 windows 7의 경로 확장자 \? 사용
def PreserveEmptyDirs(self):
preservedDirs = []
for root, dirs, files in os.walk(self.gitRepo.path, topdown=True):
for name in dirs:
path ="\\\\?\\"+ToUnixPath(os.path.join(root, name))
# Preserve empty directories that are not under the .git/ directory.
if git.GetGitDirPrefix(path) is None and len(os.listdir(path)) == 0:
filename = os.path.join(path, '.gitignore')
with codecs.open(filename, 'w', 'utf-8') as file:
#file.write('# accurev2git.py preserve empty dirs\n')
preservedDirs.append(filename)
if not os.path.exists(filename):
logger.error("Failed to preserve directory. Couldn't create '{0}'.".format(filename))
return preservedDirs
def ToUnixPath(path):
rv = SplitPath(path)
if rv is not None:
if rv[0] == '/':
rv = '/' + '/'.join(rv[1:])
else:
rv = '/'.join(rv)
return rv
def SplitPath(path):
rv = None
if path is not None:
path = str(path)
rv = []
drive, path = os.path.splitdrive(path)
head, tail = os.path.split(path)
while len(head) > 0 and head != '/' and head != '\\': # For an absolute path the starting slash isn't removed from head.
rv.append(tail)
head, tail = os.path.split(head)
if len(tail) > 0:
rv.append(tail)
if len(head) > 0: # For absolute paths.
rv.append(head)
if len(drive) > 0:
rv.append(drive)
rv.reverse()
return rv
은 "\\? \"긴 경로 길이를 허용하지만 지금은이 오류를 얻기 위해 :
이
은 ac2git.py 스크립트에서 코드의 일부이다 :FileNotFoundError: [WinError 3] The system cannot find the path specified: '\\\\?\\C:///s/cms'
저는 파이썬을 처음 접했고 그 문제를 해결할 올바른 방법이 무엇인지 잘 모릅니다. Windows 7 만 계속 사용해야합니다. 이 문제가 다른 방법으로 해결 될 수 있다면 어떤 제안이 필요합니까?
들여 쓰기를 수정하십시오. 경로 시작 부분을 \\? \ 대신 \\? \로 업데이트하면 어떻게됩니까? – rfkortekaas
같은 오류가 발생합니다. –
왜 c :? 뒤에 3 개의 슬래시가 있습니까? 그것은 하나 여야합니다. – rfkortekaas