Bug fix:
- Validate File Path and add '/' when saving JSON file
This commit is contained in:
@@ -65,12 +65,25 @@ bool CJSONparse::WriteToScreen( const char * BasePath, const int Indent )
|
|||||||
|
|
||||||
bool CJSONparse::WriteToFile( const char * BasePath, const char * Path, const char * FileName, const int Indent )
|
bool CJSONparse::WriteToFile( const char * BasePath, const char * Path, const char * FileName, const int Indent )
|
||||||
{
|
{
|
||||||
char FilePath[250] = "";
|
char FilePath[250] = "";
|
||||||
|
int PathLen = 0;
|
||||||
|
|
||||||
|
// Validate
|
||||||
|
if (!FileName) {
|
||||||
|
Error = true;
|
||||||
|
sprintf( ErrorText, "No File name specified" );
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Build file name
|
// Build file name
|
||||||
if (Path)
|
if (Path && *Path) {
|
||||||
strcpy( FilePath, Path );
|
strcpy( FilePath, Path );
|
||||||
strcat( FilePath, FileName );
|
PathLen = strlen( FilePath );
|
||||||
|
if (FilePath[PathLen] != '/') {
|
||||||
|
FilePath[PathLen++] = '/';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
strcpy( &FilePath[PathLen], FileName );
|
||||||
|
|
||||||
// Read file
|
// Read file
|
||||||
return WriteToFile( BasePath, FilePath, Indent );
|
return WriteToFile( BasePath, FilePath, Indent );
|
||||||
|
|||||||
Reference in New Issue
Block a user