Implement islink, readlink and realpath using Win32 api
Change-Id: I18452cbb32d24db73601ad10485dbe6bb278731c
diff --git a/project.py b/project.py
index d4c5afd..655b202 100644
--- a/project.py
+++ b/project.py
@@ -103,7 +103,7 @@
"""
global _project_hook_list
if _project_hook_list is None:
- d = os.path.realpath(os.path.abspath(os.path.dirname(__file__)))
+ d = platform_utils.realpath(os.path.abspath(os.path.dirname(__file__)))
d = os.path.join(d, 'hooks')
_project_hook_list = [os.path.join(d, x) for x in os.listdir(d)]
return _project_hook_list
@@ -275,7 +275,7 @@
def __linkIt(self, relSrc, absDest):
# link file if it does not exist or is out of date
- if not os.path.islink(absDest) or (os.readlink(absDest) != relSrc):
+ if not platform_utils.islink(absDest) or (platform_utils.readlink(absDest) != relSrc):
try:
# remove existing file first, since it might be read-only
if os.path.lexists(absDest):
@@ -2315,10 +2315,10 @@
print("Retrying clone after deleting %s" %
self.gitdir, file=sys.stderr)
try:
- platform_utils.rmtree(os.path.realpath(self.gitdir))
- if self.worktree and os.path.exists(os.path.realpath
+ platform_utils.rmtree(platform_utils.realpath(self.gitdir))
+ if self.worktree and os.path.exists(platform_utils.realpath
(self.worktree)):
- platform_utils.rmtree(os.path.realpath(self.worktree))
+ platform_utils.rmtree(platform_utils.realpath(self.worktree))
return self._InitGitDir(mirror_git=mirror_git, force_sync=False)
except:
raise e
@@ -2370,7 +2370,7 @@
self._InitHooks()
def _InitHooks(self):
- hooks = os.path.realpath(self._gitdir_path('hooks'))
+ hooks = platform_utils.realpath(self._gitdir_path('hooks'))
if not os.path.exists(hooks):
os.makedirs(hooks)
for stock_hook in _ProjectHooks():
@@ -2386,7 +2386,7 @@
continue
dst = os.path.join(hooks, name)
- if os.path.islink(dst):
+ if platform_utils.islink(dst):
continue
if os.path.exists(dst):
if filecmp.cmp(stock_hook, dst, shallow=False):
@@ -2448,9 +2448,9 @@
symlink_dirs += self.working_tree_dirs
to_symlink = symlink_files + symlink_dirs
for name in set(to_symlink):
- dst = os.path.realpath(os.path.join(destdir, name))
+ dst = platform_utils.realpath(os.path.join(destdir, name))
if os.path.lexists(dst):
- src = os.path.realpath(os.path.join(srcdir, name))
+ src = platform_utils.realpath(os.path.join(srcdir, name))
# Fail if the links are pointing to the wrong place
if src != dst:
_error('%s is different in %s vs %s', name, destdir, srcdir)
@@ -2482,10 +2482,10 @@
if copy_all:
to_copy = os.listdir(gitdir)
- dotgit = os.path.realpath(dotgit)
+ dotgit = platform_utils.realpath(dotgit)
for name in set(to_copy).union(to_symlink):
try:
- src = os.path.realpath(os.path.join(gitdir, name))
+ src = platform_utils.realpath(os.path.join(gitdir, name))
dst = os.path.join(dotgit, name)
if os.path.lexists(dst):
@@ -2498,7 +2498,7 @@
if name in to_symlink:
platform_utils.symlink(
os.path.relpath(src, os.path.dirname(dst)), dst)
- elif copy_all and not os.path.islink(dst):
+ elif copy_all and not platform_utils.islink(dst):
if os.path.isdir(src):
shutil.copytree(src, dst)
elif os.path.isfile(src):
@@ -2556,7 +2556,7 @@
raise
def _gitdir_path(self, path):
- return os.path.realpath(os.path.join(self.gitdir, path))
+ return platform_utils.realpath(os.path.join(self.gitdir, path))
def _revlist(self, *args, **kw):
a = []