Call this v0.5.1 -> version bump on minor function additions
This commit is contained in:
parent
d8ae96e2ed
commit
077c588d5a
2
Makefile
2
Makefile
@ -2,7 +2,7 @@
|
||||
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (GPLv2)
|
||||
# Some changes and tweaks from Menchers
|
||||
|
||||
VERSION = \"0.5.0\"
|
||||
VERSION = \"0.5.1\"
|
||||
VERSION_EXTRA = \"$(EXTRA)\"
|
||||
|
||||
PREFIX ?= /usr
|
||||
|
@ -2,7 +2,7 @@
|
||||
# (C) Copyright 2014-2021 Chris Dorman, some rights reserved (GPLv2)
|
||||
# Some changes and tweaks from Menchers
|
||||
|
||||
VERSION = \"0.5.0\"
|
||||
VERSION = \"0.5.1\"
|
||||
VERSION_EXTRA = \"$(EXTRA)\"
|
||||
|
||||
PREFIX ?= /usr
|
||||
|
23
README.txt
23
README.txt
@ -48,20 +48,18 @@ at this moment!
|
||||
* isdir "examples/" -> returns 0 for not, 1 for is
|
||||
* isfile "examples/functions.ss" -> returns 1, its there
|
||||
|
||||
* showdir (alias ls) function, example:
|
||||
* showdir -> Lists current directory (ls does the same)
|
||||
* showdir "/" -> lists '/' (ls "/" does the same)
|
||||
|
||||
* mkdir and mkfile functions, example:
|
||||
* mkfile "file.txt" -> creates empty 'file.txt'
|
||||
* File manipulation functions
|
||||
* move "file1" "file2" -> Renames/moves file1 to file2 (mv)
|
||||
* chdir "/home/user" -> Changes directory to /home/user (cd)
|
||||
* showpath -> Returns current working directory (pwd alias)
|
||||
* showdir -> Lists current directory (ls alias)
|
||||
* showdir "/" -> lists '/'
|
||||
* mkfile "file.txt" -> creates empty 'file.txt' (touch alias)
|
||||
* mkdir "testing/" -> creates directory 'testing'
|
||||
* mkfile "testing/file.txt" -> creates directory 'testing', and creates 'file.txt'
|
||||
|
||||
* Delete example:
|
||||
* delete "file.txt"
|
||||
|
||||
* Execute example:
|
||||
* exec "ls -al"
|
||||
* exec "ls -al" (alias to ~"ls -al")
|
||||
|
||||
* Slidescript compression functions, example:
|
||||
* compress "archivename" "file1 file2 dir1 dir2" -> file1, 2, dir1, 2 archived, compressed,
|
||||
@ -148,6 +146,11 @@ Changelog
|
||||
Changes between version bumps in SlideScript. Hoping to have a lightweight top-down scripting language
|
||||
by V1.0.0 release! From there it will be molding and preserving the art.
|
||||
|
||||
* V0.5.1
|
||||
* Compression and decompression bugfixes
|
||||
* System working functions (move, chdir, and showpath)
|
||||
* General clean, removed bins/ until language stabilizes
|
||||
|
||||
* V0.5.0
|
||||
* Interactive mode gives users prompt on call to slidescript (Thanks OldCoder!)
|
||||
* Added showdir (alias ls)
|
||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
102
src/functions.c
102
src/functions.c
@ -52,8 +52,108 @@ char *process_line(char *line)
|
||||
else if(strncmp("exit", tok_srch, 4) == 0)
|
||||
syn_error("ss:exit called");
|
||||
|
||||
// Move files using rename()
|
||||
else if(strncmp("move",tok_srch,4) == 0 || strncmp("mv", tok_srch, 2) == 0)
|
||||
{
|
||||
char orig_fn[MAX_STRING_BUFSIZE]; // Should never be more than 6 characters
|
||||
tok_srch = strtok(NULL, "\"");
|
||||
if(tok_srch == NULL)
|
||||
{
|
||||
syn_warn("ss:warn:move syntax error, missing quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
else if(strncmp("showdir",tok_srch,7) == 0 || strncmp("ls", tok_srch,2) == 0)
|
||||
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||
{
|
||||
syn_warn("ss:warn:move syntax error, missing filename?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(strlen(parse_vars(tok_srch)) < MAX_STRING_LEN)
|
||||
{
|
||||
strcpy(orig_fn, parse_vars(tok_srch));
|
||||
}
|
||||
else
|
||||
{
|
||||
syn_warn("ss:warn:move syntax error, missing quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* strtok to the content that will be written to file */
|
||||
tok_srch = strtok(NULL, "\"");
|
||||
if(tok_srch == NULL)
|
||||
{
|
||||
syn_warn("ss:warn:move syntax error, missing quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
tok_srch = strtok(NULL, "\"");
|
||||
if(strcmp(tok_srch, "\n") == 0 || strcmp(tok_srch, " \n") == 0)
|
||||
{
|
||||
syn_warn("ss:warn:move syntax error, missing quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(strtok(NULL, "\"") == NULL)
|
||||
{
|
||||
syn_warn("ss:warn:move syntax error, missing quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int rename_return = rename(orig_fn, parse_vars(tok_srch));
|
||||
if(rename_return < 0)
|
||||
{
|
||||
syn_warn("ss:warn:move, failed to move file");
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
// Show current directory.
|
||||
else if(strncmp("showpath", tok_srch, 8) == 0 || strncmp("pwd", tok_srch, 3) == 0)
|
||||
{
|
||||
// Get current directory, if it errors, return NULL
|
||||
if (getcwd(retbuf, sizeof(retbuf)) == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
// All good, return path
|
||||
return retbuf;
|
||||
}
|
||||
|
||||
// Change directory
|
||||
else if(strncmp("chdir", tok_srch, 5) == 0 || strncmp("cd", tok_srch, 2) == 0)
|
||||
{
|
||||
char *dirname;
|
||||
int chdir_return;
|
||||
|
||||
tok_srch = strtok(NULL, "\"");
|
||||
if(tok_srch == NULL)
|
||||
{
|
||||
syn_warn("ss:warn:chdir syntax error, missing quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(strtok(NULL, "\"") == NULL)
|
||||
{
|
||||
syn_warn("ss:warn:chdir syntax error, missing end quote?");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dirname = parse_vars(tok_srch);
|
||||
|
||||
chdir_return = chdir(dirname);
|
||||
|
||||
if(chdir_return < 0)
|
||||
{
|
||||
syn_warn("ss:warn:chdir, error changing directory");
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
else if(strncmp("showdir", tok_srch, 7) == 0 || strncmp("ls", tok_srch, 2) == 0)
|
||||
{
|
||||
char *dirname;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user