/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to bzrlib/osutils.py

  • Committer: John Arbash Meinel
  • Date: 2007-07-11 23:45:20 UTC
  • mfrom: (2601 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2643.
  • Revision ID: john@arbash-meinel.com-20070711234520-do3h7zw8skbathpz
[merge] bzr.dev 2601

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
# OR with 0 on those platforms
70
70
O_BINARY = getattr(os, 'O_BINARY', 0)
71
71
 
 
72
# On posix, use lstat instead of stat so that we can
 
73
# operate on broken symlinks. On Windows revert to stat.
 
74
lstat = getattr(os, 'lstat', os.stat)
72
75
 
73
76
def make_readonly(filename):
74
77
    """Make a filename read-only."""
75
 
    mod = os.stat(filename).st_mode
76
 
    mod = mod & 0777555
77
 
    os.chmod(filename, mod)
 
78
    mod = lstat(filename).st_mode
 
79
    if not stat.S_ISLNK(mod):
 
80
        mod = mod & 0777555
 
81
        os.chmod(filename, mod)
78
82
 
79
83
 
80
84
def make_writable(filename):
81
 
    mod = os.stat(filename).st_mode
82
 
    mod = mod | 0200
83
 
    os.chmod(filename, mod)
 
85
    mod = lstat(filename).st_mode
 
86
    if not stat.S_ISLNK(mod):
 
87
        mod = mod | 0200
 
88
        os.chmod(filename, mod)
84
89
 
85
90
 
86
91
_QUOTE_RE = None
1149
1154
        path-from-top might be unicode or utf8, but it is the correct path to
1150
1155
        pass to os functions to affect the file in question. (such as os.lstat)
1151
1156
    """
1152
 
    fs_encoding = sys.getfilesystemencoding()
 
1157
    fs_encoding = _fs_enc.upper()
1153
1158
    if (sys.platform == 'win32' or
1154
1159
        fs_encoding not in ('UTF-8', 'US-ASCII', 'ANSI_X3.4-1968')): # ascii
1155
1160
        return _walkdirs_unicode_to_utf8(top, prefix=prefix)