Added delete function to scripting language
This commit is contained in:
parent
b25886ef13
commit
d9c0775140
@ -44,7 +44,7 @@ int process_line(char *line)
|
||||
/* Check if file exists and can be opened */
|
||||
if(write_file == NULL)
|
||||
{
|
||||
printf("SlideScript: error: Cannot write to '%s'.\n", tok_srch);
|
||||
printf("ss: error: cannot write to '%s'.\n", tok_srch);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ int process_line(char *line)
|
||||
/* Check if file was opened successfully */
|
||||
if(read_file == NULL)
|
||||
{
|
||||
printf("SlideScript: error: failed to open '%s'.\n", tok_srch);
|
||||
printf("ss: error: failed to open '%s'.\n", tok_srch);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -82,6 +82,28 @@ int process_line(char *line)
|
||||
fclose(read_file);
|
||||
} /* read function */
|
||||
|
||||
else if(strncmp("delete", tok_srch, 6) == 0) {
|
||||
tok_srch = strtok(NULL, "\"");
|
||||
if(access(tok_srch, F_OK) == 0)
|
||||
{
|
||||
if(access(tok_srch, W_OK) == 0)
|
||||
{
|
||||
remove(tok_srch);
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ss: error: '%s' is not accessible", tok_srch);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("ss: error: '%s' not found", tok_srch);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
else if(strcmp(tok_srch, "\n") != 0 && strcmp(tok_srch, "") != 0) {
|
||||
if(tok_srch[strlen(tok_srch)-1] == '\n')
|
||||
{
|
||||
|
113
test.ss
113
test.ss
@ -1,117 +1,14 @@
|
||||
#!/usr/bin/slidescript
|
||||
# This is a comment
|
||||
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
testvar1=set some data into a struct
|
||||
testvar2=multiple variables work!
|
||||
futurefeature3=add $testvar2 support :)
|
||||
variable_name=anything can go after the equal and be parsed on the same line. 'works' like a champion!
|
||||
slidescript_version=v0.1.1
|
||||
slidescript_test_version=v0.0.2
|
||||
|
||||
print "Writing to file.txt in 1 second"
|
||||
sleep 1
|
||||
write "file.txt" "This is a test file"
|
||||
print "Reading from file.txt:"
|
||||
read "file.txt"
|
||||
print "Deleting file.txt"
|
||||
delete "file.txt"
|
||||
|
Loading…
x
Reference in New Issue
Block a user