Module: Gitlab::Utils::FileInfo
- Defined in:
- lib/gitlab/utils/file_info.rb
Class Method Summary collapse
-
.linked?(file) ⇒ Boolean
Returns true if: - File or directory is a symlink.
-
.shares_hard_link?(file) ⇒ Boolean
Returns: - true if file shares a hard link with another file.
Class Method Details
.linked?(file) ⇒ Boolean
Returns true if:
-
File or directory is a symlink.
-
File shares a hard link.
10 11 12 13 14 |
# File 'lib/gitlab/utils/file_info.rb', line 10 def linked?(file) stat = to_file_stat(file) stat.symlink? || shares_hard_link?(stat) end |
.shares_hard_link?(file) ⇒ Boolean
Returns:
-
true if file shares a hard link with another file.
-
false if file is a directory, as directories cannot be hard linked.
19 20 21 22 23 |
# File 'lib/gitlab/utils/file_info.rb', line 19 def shares_hard_link?(file) stat = to_file_stat(file) stat.file? && stat.nlink > 1 end |