mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-10 18:51:21 +03:00
0029252: Coding rules - eliminate GCC compiler warnings -Wformat-overflow
OSD_DirectoryIterator and OSD_FileIterator now uses TCollection_AsciiString instead of unsafe sprintf.
This commit is contained in:
parent
cf0786daf1
commit
65ada1f174
@ -100,13 +100,11 @@ static int strcmp_joker(const char *Mask,const char *Name)
|
|||||||
void OSD_DirectoryIterator::Next(){
|
void OSD_DirectoryIterator::Next(){
|
||||||
int again = 1;
|
int again = 1;
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
char full_name[255];
|
|
||||||
|
|
||||||
myFlag = false; // Initialize to nothing found
|
myFlag = false; // Initialize to nothing found
|
||||||
|
|
||||||
do{
|
do{
|
||||||
myEntry = readdir((DIR *)myDescr);
|
myEntry = readdir((DIR *)myDescr);
|
||||||
|
|
||||||
if (!myEntry){ // No file found
|
if (!myEntry){ // No file found
|
||||||
myEntry = NULL; // Keep pointer clean
|
myEntry = NULL; // Keep pointer clean
|
||||||
myFlag = Standard_False; // No more files/directory
|
myFlag = Standard_False; // No more files/directory
|
||||||
@ -119,10 +117,8 @@ char full_name[255];
|
|||||||
// if (!strcmp(entry->d_name,"..")) continue; 2 directories.
|
// if (!strcmp(entry->d_name,"..")) continue; 2 directories.
|
||||||
|
|
||||||
// Is it a directory ?
|
// Is it a directory ?
|
||||||
|
const TCollection_AsciiString aFullName = myPlace + "/" + ((struct dirent* )myEntry)->d_name;
|
||||||
sprintf(full_name,"%s/%s",myPlace.ToCString(),
|
stat(aFullName.ToCString(), &stat_buf);
|
||||||
((struct dirent *)myEntry)->d_name); // LD debug
|
|
||||||
stat(full_name, &stat_buf);
|
|
||||||
if (S_ISDIR(stat_buf.st_mode)) // Ensure me it's not a file
|
if (S_ISDIR(stat_buf.st_mode)) // Ensure me it's not a file
|
||||||
if (strcmp_joker(myMask.ToCString(), ((struct dirent *)myEntry)->d_name)){
|
if (strcmp_joker(myMask.ToCString(), ((struct dirent *)myEntry)->d_name)){
|
||||||
// Does it follow mask ?
|
// Does it follow mask ?
|
||||||
|
@ -176,13 +176,11 @@ static int strcmp_joker(char *fileMask,char *fileName)
|
|||||||
void OSD_FileIterator::Next(){
|
void OSD_FileIterator::Next(){
|
||||||
int again = 1;
|
int again = 1;
|
||||||
struct stat stat_buf;
|
struct stat stat_buf;
|
||||||
char full_name[255];
|
|
||||||
|
|
||||||
myFlag = false; // Initialize to nothing found
|
myFlag = false; // Initialize to nothing found
|
||||||
|
|
||||||
do {
|
do {
|
||||||
myEntry = readdir((DIR *)myDescr);
|
myEntry = readdir((DIR *)myDescr);
|
||||||
|
|
||||||
if (!myEntry){ // No file found
|
if (!myEntry){ // No file found
|
||||||
myEntry = NULL; // Keep pointer clean
|
myEntry = NULL; // Keep pointer clean
|
||||||
myFlag = Standard_False; // No more files/directory
|
myFlag = Standard_False; // No more files/directory
|
||||||
@ -195,14 +193,8 @@ char full_name[255];
|
|||||||
if (!strcmp(((struct dirent *)myEntry)->d_name,"..")) continue;
|
if (!strcmp(((struct dirent *)myEntry)->d_name,"..")) continue;
|
||||||
|
|
||||||
// Is it a file ?
|
// Is it a file ?
|
||||||
|
const TCollection_AsciiString aFullName = myPlace + "/" + ((struct dirent* )myEntry)->d_name;
|
||||||
sprintf(full_name,"%s/%s",myPlace.ToCString(),
|
stat(aFullName.ToCString(), &stat_buf);
|
||||||
((struct dirent *)myEntry)->d_name); // LD debug
|
|
||||||
#ifdef OCCT_DEBUG
|
|
||||||
cout << "Place : " << myPlace << endl;
|
|
||||||
cout << "FName : " << full_name << endl;
|
|
||||||
#endif
|
|
||||||
stat(full_name, &stat_buf);
|
|
||||||
if (S_ISREG(stat_buf.st_mode)) // LD : Ensure me it's a regular file
|
if (S_ISREG(stat_buf.st_mode)) // LD : Ensure me it's a regular file
|
||||||
if (strcmp_joker(myMask.ToCString(), ((struct dirent *)myEntry)->d_name)){
|
if (strcmp_joker(myMask.ToCString(), ((struct dirent *)myEntry)->d_name)){
|
||||||
// Does it follow mask ?
|
// Does it follow mask ?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user