mirror of
https://github.com/n05la3/cmdtypist
synced 2024-11-15 12:13:09 +00:00
Added a function to verify if a user exists in the user info file
This commit is contained in:
parent
a3e9c2b7bf
commit
a729d73732
@ -402,3 +402,26 @@ void make_current(FILE* file_to_remove_from)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*Ensures atleast one user account exist*/
|
||||
extern void user_test(void)
|
||||
{
|
||||
FILE *fp;
|
||||
if((fp=fopen("./speed/user_speed.info","r"))==NULL)
|
||||
{
|
||||
fprintf(stderr, "%s\n", "Fatal Error, Some files are missing");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
rewind(fp);
|
||||
char ch=getc(fp);
|
||||
if(ch==EOF)//checking if at the beginning of a character there is a charater, if not exist
|
||||
{
|
||||
fprintf(stderr, "%s\n", "No user exists yet, use <command mkuser \"username\"> to add new user");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
if(fclose(fp))
|
||||
{
|
||||
fprintf(stderr, "%s\n", "Unable to close lesson file");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user