Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
4
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Switch to GitLab Next
Sign in / Register
Toggle navigation
T
time-slime
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Analytics
Analytics
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Michael Rouse
time-slime
Commits
75ecef53
Commit
75ecef53
authored
Aug 19, 2018
by
Michael Rouse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Getting root folder of executable.
parent
0c80cd80
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
1 deletion
+43
-1
shell/args/args.c
shell/args/args.c
+35
-0
shell/args/args.h
shell/args/args.h
+3
-0
shell/shell.c
shell/shell.c
+5
-1
No files found.
shell/args/args.c
View file @
75ecef53
...
...
@@ -126,4 +126,39 @@ date_t args_parse_date(char *dateStr)
#endif
return
date
;
}
char
*
args_get_directory_of_executable
(
char
*
name
)
{
char
path
[
1000
];
path
[
0
]
=
'\0'
;
char
read_since_last_separator
[
100
];
read_since_last_separator
[
0
]
=
'\0'
;
int
i
;
int
pos
;
int
len
=
strlen
(
name
);
for
(
i
=
0
;
i
<
len
;
i
++
)
{
if
(
name
[
i
]
==
'/'
||
name
[
i
]
==
'\\'
)
{
if
(
strlen
(
path
)
>
0
)
{
pos
=
strlen
(
path
);
path
[
pos
]
=
'\\'
;
path
[
pos
+
1
]
=
'\0'
;
}
strcat
(
path
,
read_since_last_separator
);
read_since_last_separator
[
0
]
=
'\0'
;
}
else
{
pos
=
strlen
(
read_since_last_separator
);
read_since_last_separator
[
pos
]
=
name
[
i
];
read_since_last_separator
[
pos
+
1
]
=
'\0'
;
}
}
char
*
result
=
malloc
(
sizeof
(
path
));
strcpy
(
result
,
path
);
return
result
;
}
\ No newline at end of file
shell/args/args.h
View file @
75ecef53
...
...
@@ -33,4 +33,7 @@ args_t args_parse(int argc, char **argv);
/* Parse into a date */
date_t
args_parse_date
(
char
*
date
);
char
*
args_get_directory_of_executable
(
char
*
name
);
#endif
\ No newline at end of file
shell/shell.c
View file @
75ecef53
...
...
@@ -18,7 +18,8 @@ int main(int argc, char *argv[])
{
log_dull
(
"==== Time Slime ====
\n
"
)
status
=
TimeSlime_Initialize
(
"build"
);
char
*
base_folder
=
args_get_directory_of_executable
(
argv
[
0
]);
status
=
TimeSlime_Initialize
(
base_folder
);
if
(
status
!=
TIMESLIME_OK
)
{
printf
(
"An error occured: %d
\n
"
,
status
);
...
...
@@ -51,6 +52,9 @@ int main(int argc, char *argv[])
TimeSlime_Close
();
free
(
base_folder
);
base_folder
=
NULL
;
return
0
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment