如何在不使用實際的touch
可執行文件的情況下實現獨立於平臺的觸摸?我不能依賴於PATH中的touch
,或者甚至不存在於特定系統上。平臺無關的文件觸摸方式?
1
A
回答
1
創建一個空文件並將原始文件+空文件複製回原始文件。我只是在Windows上測試它,它工作。
C:\tmp>dir \utils\emp* Volume in drive C has no label. Volume Serial Number is BC80-0D15 Directory of C:\utils 2011-03-14 11:58 0 empty_file 1 File(s) 0 bytes 0 Dir(s) 27,506,368,512 bytes free C:\tmp>dir *.gif Volume in drive C has no label. Volume Serial Number is BC80-0D15 Directory of C:\tmp 2010-10-08 12:00 20,463 cknight.gif 2009-10-30 17:31 1,298,525 img-big.gif 2009-10-30 17:46 225,992 img.gif 3 File(s) 1,544,980 bytes 0 Dir(s) 27,506,368,512 bytes free C:\tmp>copy /b img.gif+\Utils\empty_file /b img.gif img.gif \Utils\empty_file 1 file(s) copied. C:\tmp>dir *.gif Volume in drive C has no label. Volume Serial Number is BC80-0D15 Directory of C:\tmp 2010-10-08 12:00 20,463 cknight.gif 2009-10-30 17:31 1,298,525 img-big.gif 2011-03-14 12:07 225,992 img.gif 3 File(s) 1,544,980 bytes 0 Dir(s) 27,506,368,512 bytes free C:\tmp>
1
touch是一個非常簡單的程序。您可以輕鬆提取基本步驟並將其作爲系統中的子例程來實現。見the source code。
touch取決於utime()
,這是POSIX,應該在大多數平臺上可用。
或者,您可以將自己的觸摸實現作爲可執行文件提供(如果需要從腳本調用它)。
相關問題
- 1. UIView關閉觸摸事件的方式
- 2. Windows平臺上類似「觸摸」(即Node.js的方式來創建一個index.html)
- 3. 無法獲得觸摸事件委託方法觸摸uiimageview
- 4. 查找字體的平臺無關的方式
- 5. 重新啓動Equinox容器的平臺無關的方式?
- 6. 檢測Java中處理器數量的平臺無關方式
- 7. 正確的方式scanf和printf size_t變量(平臺無關)
- 8. 3D觸摸快捷方式小部件
- 9. 關於UITableView觸摸事件
- 10. 防止uitableview在水平觸摸後取消觸摸事件
- 11. ios中的平滑觸摸
- 12. NetBeans平臺無法關閉
- 13. C#單(平臺無關性)
- 14. 平臺無關目標C
- 15. MapActivity強制關閉,觸摸事件無情地觸發
- 16. Android觸摸事件方向
- 17. 如何以平臺無關的方式選擇無窮大的值
- 18. 逐行分割文本文件,平臺無關
- 19. 平臺無關的方式來按照文件類型來關閉外部應用程序/幫助程序?
- 20. JavaFX ScrollPane:禁用觸摸事件平移
- 21. 平臺無關的內存映射[文件] IO
- 22. 如何實現平臺無關的異步寫入文件?
- 23. 具有無阻塞控制檯輸入的跨平臺方式
- 24. 觸摸事件沒有觸及方法?
- 25. 平滑移動與觸摸
- 26. 任何讀取文本文件的頭文件與平臺無關?
- 27. 關於在Android中的觸摸事件
- 28. Android的觸摸事件力關閉
- 29. 手勢和觸摸事件 - 平穩調整方形
- 30. 使用Java 1.5跨平臺打開文件的方式
我認爲通過運行不帶參數的'touch',它會修改上次修改的時間戳。這就是我所追求的。 – Geo 2011-03-14 11:30:44
@geo:我用可能的解決方案編輯了我的答案 – maraguida 2011-03-14 12:13:38