Skip to content

Instantly share code, notes, and snippets.

@tomfa
Last active September 9, 2018 15:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomfa/5fd21164520c1d522323a4619d80ea6f to your computer and use it in GitHub Desktop.
Save tomfa/5fd21164520c1d522323a4619d80ea6f to your computer and use it in GitHub Desktop.
Pseudocode for check file thingy
function does_file_exist(filename):
...
function get_modified_at(filename):
...
function print_file_is_deleted(filename):
...
function print_file_is_created(filename):
...
function print_file_modified(filename):
...
# Get from command line arguments
filename = ...
sleep_interval = ...
file_exists = does_file_exist(filename)
last_modified_at = get_modified_at(filename)
while True:
does_file_exist_now = does_file_exist(filename)
if does_file_exist_now and not file_exists:
print_file_is_created(filename)
file_exists = True
elif not does_file_exist_now and file_exists:
print_file_is_deleted(filename)
file_exists = False
elif file_exists:
new_modified_at = get_modified_at(filename)
if new_modified_at != last_modified_at:
print_file_modified(filename, new_modified_at)
last_modified_at = new_modified_at
sleep(sleep_interval)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment