Last active
September 9, 2018 15:27
-
-
Save tomfa/5fd21164520c1d522323a4619d80ea6f to your computer and use it in GitHub Desktop.
Pseudocode for check file thingy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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