Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions c/job.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ int create_job(const char *dir) {
cleanup:
fclose(jobfile);


remove(jobfname);
printf("Deleted %s\n",jobfname);
free(jobfname);
jobfname = NULL;

Expand Down
9 changes: 9 additions & 0 deletions c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,15 @@ int main(int argc, const char *argv[]) {
}

cleanup:
printf("cleaning up!\n");
char cmd[128] = {0};
snprintf(cmd, 128, "rmdir %s", dir);
int ret = system(cmd);
if (ret==0){
printf("removed directory \"%s\" successfully\n", dir);
} else {
printf("error removing directory \"%s\"\n", dir);
}
free(dir);
dir = NULL;

Expand Down
4 changes: 4 additions & 0 deletions java/src/main/java/ca/uwaterloo/cs489/exercise2/Job.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,8 @@ public int processJob() {
}

public int getInput() { return this.input; }

public void deleteFile() {
file.delete();
}
}
7 changes: 7 additions & 0 deletions java/src/main/java/ca/uwaterloo/cs489/exercise2/MainApp.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ca.uwaterloo.cs489.exercise2;

import java.io.BufferedReader;
import java.io.File;
import java.io.InputStreamReader;
import java.io.IOException;
import java.io.FileNotFoundException;
Expand Down Expand Up @@ -35,7 +36,13 @@ public static void main(String[] args) {
for (Path entry : ds) {
Job job = new Job(entry.toFile());
logger.info(String.format("Job %d yields %d\n", job.getInput(), job.processJob()));
job.deleteFile();
logger.info("Deleted file for Job %d\n",job.getInput());
}
File dirFile = dir.toFile();
dirFile.delete();
logger.info("Deleted directory \"%s\"\n",dir.toString());

} catch (IOException e) {
e.printStackTrace();
}
Expand Down