唯一标识文件 [英] Uniquely identify files
问题描述
这将用于* nix / Linux和ext4所以请特别注意windows或ntfs或类似的东西。
可能会考虑使用文件的inode number属性,在shell中可以看到 ls -i
。 使用索引.php在我的一个箱子里:
$ b $ p $ l $ c $ ls -i
产生
196237 index.php
<然后使用
mv index.php index1.php
重命名文件,之后相同的 ls -i
: 196237 index1.php
inode号码是相同的)
I'd like to index files in a local database but I do not understand how I can identified each individual file. For example if I store the file path in the database then the entry will no longer be valid if the file is moved or deleted. I imagine there is some way of uniquely identifying files no matter what happens to them but I have had no success with Google.
This will be for *nix/Linux and ext4 in particular, so please nothing specific to windows or ntfs or anything like that.
In addition to the excellent suggestion above, you might consider using the inode number property of the files, viewable in a shell with ls -i
.
Using index.php on one of my boxes:
ls -i
yields
196237 index.php
I then rename the file using mv index.php index1.php
, after which the same ls -i
yields:
196237 index1.php
(Note the inode number is the same)
这篇关于唯一标识文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!