tretries.nim 309 B

123456789101112131415161718192021
  1. discard """
  2. retries: 2
  3. """
  4. import os
  5. const tempFile = "tretries_temp"
  6. if not fileExists(tempFile):
  7. writeFile(tempFile, "abc")
  8. quit(1)
  9. else:
  10. let content = readFile(tempFile)
  11. if content == "abc":
  12. writeFile(tempFile, "def")
  13. quit(1)
  14. else:
  15. # success
  16. removeFile(tempFile)
  17. discard