首页 > 其他分享 >目录时间戳的规律

目录时间戳的规律

时间:2024-01-25 12:22:58浏览次数:18  
标签:sub end name deep 时间 file 目录 dir 规律

1
2
3
4
5
6
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
# Copyright © 2022, 飞麦 <[email protected]>, All rights reserved.

# frozen_string_literal: true

# 测试目录各时间戳的规律(通用)
class Dirtime
    def result(newtime, oldtime)
        newtime == oldtime ? '不变' : '变'
    end

    def compare(title)
        new_stat = File.stat(@cur_dir_name)
        puts "#{title} 目录创建时刻 #{result(new_stat.ctime, @cur_stat.ctime)}"
        puts "#{title} 目录修改时刻 #{result(new_stat.mtime, @cur_stat.mtime)}"
        puts "#{title} 目录存取时刻 #{result(new_stat.atime, @cur_stat.atime)}"
        @cur_stat = new_stat
    end

    def test(func, title)
        sleep(0.01)
        method(func).call
        compare(title)
    end
end

# 测试目录各时间戳的规律(孙目录级)
class Dirtime
    def create_deep_dir
        Dir.mkdir(@deep_dir_name)
    end

    def create_deep_file
        File.write(@deep_file_name, '~' * 4096)
    end

    def change_deep_dir_name
        File.rename(@deep_dir_name, '壬申猴')
        File.rename('壬申猴', @deep_dir_name)
    end

    def change_deep_dir_attr
        system("attrib.exe +h #{@deep_dir_name}")
        system("attrib.exe -h #{@deep_dir_name}")
    end

    def remove_deep_dir
        Dir.rmdir(@deep_dir_name)
    end

    def change_deep_file_name
        File.rename(@deep_file_name, '癸酉鸡')
        File.rename('癸酉鸡', @deep_file_name)
    end

    def change_deep_file_attr
        system("attrib.exe +h #{@deep_file_name}")
        system("attrib.exe -h #{@deep_file_name}")
    end

    def change_deep_file_text
        File.write(@deep_file_name, '&' * 4096)
    end

    def remove_deep_file
        File.delete(@deep_file_name)
    end

    # 测试孙目录
    def check_deep
        test(:create_deep_dir, '创建孙目录')
        test(:create_deep_file, '创建孙文件')
        test(:change_deep_dir_name, '改变孙目录名称')
        test(:change_deep_dir_attr, '变更孙目录属性')
        test(:remove_deep_dir, '删除孙目录')
        test(:change_deep_file_name, '改变孙文件名称')
        test(:change_deep_file_attr, '变更孙文件属性')
        test(:change_deep_file_text, '修改孙文件内容')
        test(:remove_deep_file, '删除孙文件')
    end

    def deal_deep
        @deep_dir_name = '庚午马'
        @deep_file_name = '辛未羊'
        Dir.chdir(@sub_dir_name) do
            check_deep
        end
    end
end

# 测试目录各时间戳的规律(子目录级)
class Dirtime
    def create_sub_dir
        Dir.mkdir(@sub_dir_name)
    end

    def create_sub_file
        File.write(@sub_file_name, '~' * 4096)
    end

    def query_sub_dir
        Dir.chdir(@sub_dir_name) do
            Dir.glob('*')
        end
    end

    def change_sub_dir_name
        File.rename(@sub_dir_name, '戊辰龙')
        File.rename('戊辰龙', @sub_dir_name)
    end

    def change_sub_dir_attr
        system("attrib.exe +h #{@sub_dir_name}")
        system("attrib.exe -h #{@sub_dir_name}")
    end

    def remove_sub_dir
        Dir.rmdir(@sub_dir_name)
    end

    def change_sub_file_name
        File.rename(@sub_file_name, '己巳蛇')
        File.rename('己巳蛇', @sub_file_name)
    end

    def change_sub_file_attr
        system("attrib.exe +h #{@sub_file_name}")
        system("attrib.exe -h #{@sub_file_name}")
    end

    def change_sub_file_text
        File.write(@sub_file_name, '&' * 4096)
    end

    def remove_sub_file
        File.delete(@sub_file_name)
    end

    def check_sub
        test(:create_sub_dir, '创建子目录')
        test(:create_sub_file, '创建子文件')
        test(:query_sub_dir, '查询子目录列表')
        test(:change_sub_dir_name, '改变子目录名称')
        test(:change_sub_dir_attr, '变更子目录属性')
        deal_deep
        test(:remove_sub_dir, '删除子目录')
        test(:change_sub_file_name, '改变子文件名称')
        test(:change_sub_file_attr, '变更子文件属性')
        test(:change_sub_file_text, '修改子文件内容')
        test(:remove_sub_file, '删除子文件')
    end

    def deal_sub
        @sub_dir_name = '丙寅虎'
        @sub_file_name = '丁卯兔'
        Dir.chdir(@cur_dir_name) do
            check_sub
        end
    end
end

# 测试目录各时间戳的规律(目录级)
class Dirtime
    def change_cur_name
        File.rename(@cur_dir_name, '乙丑牛')
        File.rename('乙丑牛', @cur_dir_name)
    end

    def change_cur_attr
        system("attrib.exe +h #{@cur_dir_name}")
        system("attrib.exe -h #{@cur_dir_name}")
    end

    def query_cur_dir
        Dir.glob('*')
    end

    def check_cur
        test(:change_cur_name, '改变目录名称')
        test(:change_cur_attr, '变更目录属性')
        test(:query_cur_dir, '查询目录列表')
    end
end

# 测试目录各时间戳的规律
class Dirtime
    def init_cur
        @cur_dir_name = File.join(Dir.home, '甲子鼠')
        Dir.mkdir(@cur_dir_name)
        @cur_stat = File.stat(@cur_dir_name)
        puts '测试目录的时间戳:'
    end

    def recover_current
        Dir.rmdir(@cur_dir_name)
    end

    def main
        Dir.chdir(Dir.home) do
            init_cur
            check_cur
            deal_sub
            recover_current
        end
        puts '总结:'
        puts '当前目录的创建时间戳:创建当前目录时记录,后续操作不再改变。'
        puts '当前目录的修改与存取时间戳:创建、改名、删除子目录或子文件时改变,修改子文件内容及操作孙目录时不变。'
    end
end

$PROGRAM_NAME == __FILE__ && Dirtime.new.main

标签:sub,end,name,deep,时间,file,目录,dir,规律
From: https://www.cnblogs.com/fitmap/p/17986894

相关文章

  • js date时间设置
    //获取上个月最后一天vardate1=newDate();//console.log(date1);//当天date1.setDate(0);//setDate(day)方法用于设置一个月的某一天。day取1-31表示对应的天数,另外0为上一个月的最后一天,-1为上一个月最后一天之前的一天,32为下个月的第一天或者第二天//console.log(date1......
  • PYTHON 用几何布朗运动模型和蒙特卡罗MONTE CARLO随机过程模拟股票价格可视化分析耐克
    原文链接:http://tecdat.cn/?p=27099最近我们被客户要求撰写关于蒙特卡罗的研究报告,包括一些图形和统计输出。金融资产/证券已使用多种技术进行建模。该项目的主要目标是使用几何布朗运动模型和蒙特卡罗模拟来模拟股票价格。该模型基于受乘性噪声影响的随机(与确定性相反)变量该项......
  • WGCLOUD接口监测多长时间扫描一次
    10分钟WGCLOUD的服务接口监测,默认10分钟监测一次,不过也可以修改在server配置文件里修改如下配置项即可,修改后重启下server就生效了#服务接口监控间隔,单位秒,默认10分钟heathTimes:600......
  • el-date-picker日期选择器默认值,时间跨度90天
    ElementUIDatePicker1.时间范围选择器,默认加载30天,输入开始时间,结束时间只能选90天内的,90天外的禁用不能选。1<el-date-picker2v-model="value"3clearable4style="width:100%"......
  • Linux系统目录和相对路径与绝对路径
    1、系统目录结构Linux只有一个根目录使用tree命令查看linux目录结构[root@fishman-160/]#tree-L1#仅下降一级目录的深度。.├──bin->usr/bin├──boot├──dev├──etc├──home├──lib->usr/lib├──lib64->usr/lib64├──media├─......
  • Flink 中的时间和窗口
    在批处理统计中,我们可以等待一批数据都到齐后,统一处理。但是在实时处理统计中,我们是来一条就得处理一条,那么我们怎么统计最近一段时间内的数据呢?引入“窗口”。所谓的“窗口”,一般就是划定的一段时间范围,也就是“时间窗”;对在这范围内的数据进行处理,就是所谓的窗口计算。所以窗口......
  • 麒麟操作系统登录界面的等待时间
    如何在grub添加启动参数WelcometoopenKylin1.0(GNU/Linux6.1.0-3-genericx86_64)*Support:https://openkylin.topLastlogin:TueJan2320:20:132024from192.168.10.1*Support:https://openkylin.topLastlogin:TueJan2320:20:132024f......
  • java Future多个任务的超时时间问题
    问题publicstaticvoidmain(String[]args)throwsInterruptedException,ExecutionException,TimeoutException{ExecutorServiceexecutor=Executors.newSingleThreadExecutor();Future<String>future=executor.submit(()->"......
  • 鸿蒙5.0发布时间已定!鸿蒙系统上的App开发新思路
    直接在百度上搜索「鸿蒙5.0发布时间」,出来的结果,那一个比一个焦虑~~百度的AI基于综合内容判断得出,鸿蒙5.0的发布时间在2023-04-17百度知道推的答案是202年年4月中但不管几月,“鸿蒙元年”似乎都是确定的,就是2024年。   鸿蒙5.0如此独特,直接引导......
  • 马伟明:任何事物,只要抓住了规律,就等于牵住了牛鼻子
        马伟明:获国家科技进步一等奖2项。全国十大“杰出专业技术人才”、十佳“全国优秀科技工作者”、“有突出贡献的中青年专家”,一等功荣立者。海军少将,2017年7月28日获得“八一勋章”    马伟明的思维的确有过人之处。在一般人看来,抽象的事物是最枯燥、最乏味,但在他......