Show More
@@ -991,6 +991,9 b" if os.name == 'nt':" | |||
|
991 | 991 | def set_link(f, mode): |
|
992 | 992 | pass |
|
993 | 993 | |
|
994 | def set_flags(f, flags): | |
|
995 | pass | |
|
996 | ||
|
994 | 997 | def set_binary(fd): |
|
995 | 998 | msvcrt.setmode(fd.fileno(), os.O_BINARY) |
|
996 | 999 | |
@@ -1174,6 +1177,34 b' else:' | |||
|
1174 | 1177 | os.unlink(f) |
|
1175 | 1178 | file(f, "w").write(data) |
|
1176 | 1179 | |
|
1180 | def set_flags(f, flags): | |
|
1181 | s = os.lstat(f).st_mode | |
|
1182 | x = "x" in flags | |
|
1183 | l = "l" in flags | |
|
1184 | if l: | |
|
1185 | if not stat.S_ISLNK(s): | |
|
1186 | # switch file to link | |
|
1187 | data = file(f).read() | |
|
1188 | os.unlink(f) | |
|
1189 | os.symlink(data, f) | |
|
1190 | # no chmod needed at this point | |
|
1191 | return | |
|
1192 | if stat.S_ISLNK(s): | |
|
1193 | # switch link to file | |
|
1194 | data = os.readlink(f) | |
|
1195 | os.unlink(f) | |
|
1196 | file(f, "w").write(data) | |
|
1197 | s = 0666 & ~_umask # avoid restatting for chmod | |
|
1198 | ||
|
1199 | sx = s & 0100 | |
|
1200 | if x and not sx: | |
|
1201 | # Turn on +x for every +r bit when making a file executable | |
|
1202 | # and obey umask. | |
|
1203 | os.chmod(f, s | (s & 0444) >> 2 & ~_umask) | |
|
1204 | elif not x and sx: | |
|
1205 | # Turn off all +x bits | |
|
1206 | os.chmod(f, s & 0666) | |
|
1207 | ||
|
1177 | 1208 | def set_binary(fd): |
|
1178 | 1209 | pass |
|
1179 | 1210 |
General Comments 0
You need to be logged in to leave comments.
Login now