7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
# File 'src/symlink.rb', line 7
def supported?
return @supported if defined?(@supported)
return @supported if @mutex.nil?
@mutex.synchronize do
target_path = ".foobara-symlink-test-target"
symlink_path = ".foobara-symlink-test-link"
@supported = begin
FileUtils.rm_f(target_path)
FileUtils.rm_f(symlink_path)
File.write(target_path, "hi!")
File.symlink(target_path, symlink_path)
File.symlink?(symlink_path)
rescue Errno::EACCES, NotImplementedError, SystemCallError
false
ensure
FileUtils.rm_f(target_path)
FileUtils.rm_f(symlink_path)
end
@mutex = nil
@supported
end
end
|