mirror of https://github.com/acanas/swad-core.git
Version 15.70.5
This commit is contained in:
parent
5ef7ba86e8
commit
e89f26fd49
|
@ -118,12 +118,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 15.70.3 (2015/12/21)"
|
#define Log_PLATFORM_VERSION "SWAD 15.70.5 (2015/12/21)"
|
||||||
#define CSS_FILE "swad15.65.1.css"
|
#define CSS_FILE "swad15.65.1.css"
|
||||||
|
|
||||||
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
// Number of lines (includes comments but not blank lines) has been got with the following command:
|
||||||
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
// nl swad*.c swad*.h css/swad*.css py/swad*.py js/swad*.js soap/swad*.h sql/swad*.sql | tail -1
|
||||||
/*
|
/*
|
||||||
|
Version 15.70.5: Dec 21, 2015 Code refactoring in file browser. (187569 lines)
|
||||||
|
Version 15.70.4: Dec 21, 2015 Code refactoring in file browser. (187527 lines)
|
||||||
Version 15.70.3: Dec 21, 2015 Code refactoring in file browser. (187490 lines)
|
Version 15.70.3: Dec 21, 2015 Code refactoring in file browser. (187490 lines)
|
||||||
Version 15.70.2: Dec 21, 2015 Users can selected number of months in form to remove old files in briefcase. Not finished. (187473 lines)
|
Version 15.70.2: Dec 21, 2015 Users can selected number of months in form to remove old files in briefcase. Not finished. (187473 lines)
|
||||||
Version 15.70.1: Dec 21, 2015 Removing old files in briefcase. Not finished. (187408 lines)
|
Version 15.70.1: Dec 21, 2015 Removing old files in briefcase. Not finished. (187408 lines)
|
||||||
|
|
41
swad_file.c
41
swad_file.c
|
@ -415,7 +415,8 @@ void Fil_CreateDirIfNotExists (const char *Path)
|
||||||
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDirectory)
|
void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDirectory)
|
||||||
{
|
{
|
||||||
struct dirent **FileList;
|
struct dirent **FileList;
|
||||||
int NumFile,NumFilesInsideDir;
|
int NumFile;
|
||||||
|
int NumFiles;
|
||||||
char Path2[PATH_MAX+1];
|
char Path2[PATH_MAX+1];
|
||||||
struct stat FileStatus;
|
struct stat FileStatus;
|
||||||
|
|
||||||
|
@ -423,25 +424,33 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDire
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
{
|
{
|
||||||
/***** Scan the directory *****/
|
/***** Scan the directory *****/
|
||||||
NumFilesInsideDir = scandir (Path,&FileList,NULL,NULL);
|
if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error
|
||||||
|
{
|
||||||
/* Loop over files */
|
/* Loop over files */
|
||||||
for (NumFile = 0;
|
for (NumFile = 0;
|
||||||
NumFile < NumFilesInsideDir;
|
NumFile < NumFiles;
|
||||||
NumFile++)
|
NumFile++)
|
||||||
if (strcmp (FileList[NumFile]->d_name,".") &&
|
|
||||||
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
|
||||||
{
|
{
|
||||||
sprintf (Path2,"%s/%s",Path,FileList[NumFile]->d_name);
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
|
{
|
||||||
|
sprintf (Path2,"%s/%s",Path,FileList[NumFile]->d_name);
|
||||||
|
Fil_RemoveOldTmpFiles (Path2,TimeToRemove,true); // Recursive call
|
||||||
|
}
|
||||||
|
free ((void *) FileList[NumFile]);
|
||||||
}
|
}
|
||||||
if (RemoveDirectory)
|
free ((void *) FileList);
|
||||||
/* Remove the directory itself */
|
|
||||||
if (Gbl.StartExecutionTimeUTC - FileStatus.st_mtime > TimeToRemove)
|
if (RemoveDirectory)
|
||||||
rmdir (Path);
|
/* Remove the directory itself */
|
||||||
|
if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove)
|
||||||
|
rmdir (Path);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (Gbl.StartExecutionTimeUTC - FileStatus.st_mtime > TimeToRemove)
|
if (FileStatus.st_mtime < Gbl.StartExecutionTimeUTC - TimeToRemove)
|
||||||
unlink (Path);
|
unlink (Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4612,44 +4612,47 @@ void Brw_CalcSizeOfDir (char *Path)
|
||||||
static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
||||||
{
|
{
|
||||||
struct dirent **FileList;
|
struct dirent **FileList;
|
||||||
int NumFileInThisDir;
|
int NumFile;
|
||||||
int NumFilesInThisDir;
|
int NumFiles;
|
||||||
char PathFileRel[PATH_MAX+1];
|
char PathFileRel[PATH_MAX+1];
|
||||||
struct stat FileStatus;
|
struct stat FileStatus;
|
||||||
|
|
||||||
/***** Scan the directory *****/
|
/***** Scan the directory *****/
|
||||||
NumFilesInThisDir = scandir (Path,&FileList,NULL,NULL);
|
if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error
|
||||||
|
|
||||||
/***** Compute recursively the total number and size of the files and folders *****/
|
|
||||||
for (NumFileInThisDir = 0;
|
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
|
||||||
NumFileInThisDir++)
|
|
||||||
{
|
{
|
||||||
if (strcmp (FileList[NumFileInThisDir]->d_name,".") &&
|
/***** Compute recursively the total number and size of the files and folders *****/
|
||||||
strcmp (FileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
for (NumFile = 0;
|
||||||
|
NumFile < NumFiles;
|
||||||
|
NumFile++)
|
||||||
{
|
{
|
||||||
/* There are files in this directory ==> update level */
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
if (Level > Gbl.FileBrowser.Size.NumLevls)
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
Gbl.FileBrowser.Size.NumLevls++;
|
{
|
||||||
|
/* There are files in this directory ==> update level */
|
||||||
|
if (Level > Gbl.FileBrowser.Size.NumLevls)
|
||||||
|
Gbl.FileBrowser.Size.NumLevls++;
|
||||||
|
|
||||||
/* Update counters depending on whether it's a directory or a regular file */
|
/* Update counters depending on whether it's a directory or a regular file */
|
||||||
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFileInThisDir]->d_name);
|
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFile]->d_name);
|
||||||
lstat (PathFileRel,&FileStatus);
|
lstat (PathFileRel,&FileStatus);
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
{
|
{
|
||||||
Gbl.FileBrowser.Size.NumFolds++;
|
Gbl.FileBrowser.Size.NumFolds++;
|
||||||
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
||||||
Brw_CalcSizeOfDirRecursive (Level+1,PathFileRel);
|
Brw_CalcSizeOfDirRecursive (Level + 1,PathFileRel);
|
||||||
}
|
}
|
||||||
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
||||||
{
|
{
|
||||||
Gbl.FileBrowser.Size.NumFiles++;
|
Gbl.FileBrowser.Size.NumFiles++;
|
||||||
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
free ((void *) FileList[NumFile]);
|
||||||
}
|
}
|
||||||
free (FileList[NumFileInThisDir]);
|
free ((void *) FileList);
|
||||||
}
|
}
|
||||||
free (FileList);
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -4658,63 +4661,81 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
||||||
|
|
||||||
static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
||||||
{
|
{
|
||||||
struct dirent **DirFileList;
|
struct dirent **FileList;
|
||||||
struct dirent **SubdirFileList;
|
struct dirent **SubdirFileList;
|
||||||
int NumFileInThisDir;
|
int NumFile;
|
||||||
int NumFilesInThisDir;
|
int NumFiles;
|
||||||
int NumFilesInThisSubdir;
|
int NumFileInSubdir;
|
||||||
|
int NumFilesInSubdir;
|
||||||
char PathFileRel[PATH_MAX+1];
|
char PathFileRel[PATH_MAX+1];
|
||||||
char PathFileInExplTree[PATH_MAX+1];
|
char PathFileInExplTree[PATH_MAX+1];
|
||||||
struct stat FileStatus;
|
struct stat FileStatus;
|
||||||
Brw_ExpandTree_t ExpandTree;
|
Brw_ExpandTree_t ExpandTree = Brw_EXPAND_TREE_NOTHING; // Initialized to avoid warning
|
||||||
|
|
||||||
/***** Scan directory *****/
|
/***** Scan directory *****/
|
||||||
NumFilesInThisDir = scandir (Path,&DirFileList,NULL,alphasort);
|
if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
|
||||||
|
{
|
||||||
/***** List files *****/
|
/***** List files *****/
|
||||||
for (NumFileInThisDir = 0;
|
for (NumFile = 0;
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
NumFile < NumFiles;
|
||||||
NumFileInThisDir++)
|
NumFile++)
|
||||||
if (strcmp (DirFileList[NumFileInThisDir]->d_name,".") &&
|
{
|
||||||
strcmp (DirFileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
{
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
sprintf (PathFileRel ,"%s/%s",Path ,DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
sprintf (PathFileInExplTree,"%s/%s",PathInTree,DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
|
|
||||||
lstat (PathFileRel,&FileStatus);
|
|
||||||
|
|
||||||
/***** Construct the full path of the file or folder *****/
|
|
||||||
Brw_SetFullPathInTree (PathInTree,DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
|
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
|
||||||
{
|
{
|
||||||
if (Gbl.FileBrowser.FullTree)
|
sprintf (PathFileRel ,"%s/%s",Path ,FileList[NumFile]->d_name);
|
||||||
ExpandTree = Brw_EXPAND_TREE_NOTHING;
|
sprintf (PathFileInExplTree,"%s/%s",PathInTree,FileList[NumFile]->d_name);
|
||||||
else
|
|
||||||
{
|
|
||||||
/***** Check if this subdirectory has files or folders in it *****/
|
|
||||||
if ((NumFilesInThisSubdir = scandir (PathFileRel,&SubdirFileList,NULL,NULL)) <= 2)
|
|
||||||
ExpandTree = Brw_EXPAND_TREE_NOTHING;
|
|
||||||
else
|
|
||||||
/***** Check if the tree starting at this subdirectory must be expanded *****/
|
|
||||||
ExpandTree = Brw_GetIfExpandedTree (Gbl.FileBrowser.Priv.FullPathInTree) ? Brw_EXPAND_TREE_MINUS :
|
|
||||||
Brw_EXPAND_TREE_PLUS;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Write a row for the subdirectory *****/
|
lstat (PathFileRel,&FileStatus);
|
||||||
if (Brw_WriteRowFileBrowser (Level,Brw_IS_FOLDER,ExpandTree,PathInTree,DirFileList[NumFileInThisDir]->d_name))
|
|
||||||
if (ExpandTree == Brw_EXPAND_TREE_MINUS ||
|
/***** Construct the full path of the file or folder *****/
|
||||||
ExpandTree == Brw_EXPAND_TREE_NOTHING)
|
Brw_SetFullPathInTree (PathInTree,FileList[NumFile]->d_name);
|
||||||
if (Level < Brw_MAX_DIR_LEVELS)
|
|
||||||
/* List subtree starting at this this directory */
|
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
Brw_ListDir (Level+1,PathFileRel,PathFileInExplTree);
|
{
|
||||||
|
if (Gbl.FileBrowser.FullTree)
|
||||||
|
ExpandTree = Brw_EXPAND_TREE_NOTHING;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/***** Check if this subdirectory has files or folders in it *****/
|
||||||
|
if ((NumFilesInSubdir = scandir (PathFileRel,&SubdirFileList,NULL,NULL)) >= 0) // No error
|
||||||
|
{
|
||||||
|
if (NumFilesInSubdir <= 2)
|
||||||
|
ExpandTree = Brw_EXPAND_TREE_NOTHING;
|
||||||
|
else
|
||||||
|
/***** Check if the tree starting at this subdirectory must be expanded *****/
|
||||||
|
ExpandTree = Brw_GetIfExpandedTree (Gbl.FileBrowser.Priv.FullPathInTree) ? Brw_EXPAND_TREE_MINUS :
|
||||||
|
Brw_EXPAND_TREE_PLUS;
|
||||||
|
for (NumFileInSubdir = 0;
|
||||||
|
NumFileInSubdir < NumFilesInSubdir;
|
||||||
|
NumFileInSubdir++)
|
||||||
|
free ((void *) SubdirFileList[NumFileInSubdir]);
|
||||||
|
free ((void *) SubdirFileList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Write a row for the subdirectory *****/
|
||||||
|
if (Brw_WriteRowFileBrowser (Level,Brw_IS_FOLDER,ExpandTree,PathInTree,FileList[NumFile]->d_name))
|
||||||
|
if (ExpandTree == Brw_EXPAND_TREE_MINUS ||
|
||||||
|
ExpandTree == Brw_EXPAND_TREE_NOTHING)
|
||||||
|
if (Level < Brw_MAX_DIR_LEVELS)
|
||||||
|
/* List subtree starting at this this directory */
|
||||||
|
Brw_ListDir (Level + 1,PathFileRel,PathFileInExplTree);
|
||||||
|
}
|
||||||
|
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
||||||
|
Brw_WriteRowFileBrowser (Level,
|
||||||
|
Str_FileIs (FileList[NumFile]->d_name,"url") ? Brw_IS_LINK :
|
||||||
|
Brw_IS_FILE,
|
||||||
|
Brw_EXPAND_TREE_NOTHING,PathInTree,FileList[NumFile]->d_name);
|
||||||
}
|
}
|
||||||
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
free ((void *) FileList[NumFile]);
|
||||||
Brw_WriteRowFileBrowser (Level,
|
|
||||||
Str_FileIs (DirFileList[NumFileInThisDir]->d_name,"url") ? Brw_IS_LINK :
|
|
||||||
Brw_IS_FILE,
|
|
||||||
Brw_EXPAND_TREE_NOTHING,PathInTree,DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
}
|
}
|
||||||
|
free ((void *) FileList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -6184,18 +6205,25 @@ void Brw_RemoveTree (const char *Path)
|
||||||
{
|
{
|
||||||
/***** Remove each directory and file under this directory *****/
|
/***** Remove each directory and file under this directory *****/
|
||||||
/* Scan the directory */
|
/* Scan the directory */
|
||||||
NumFiles = scandir (Path,&FileList,NULL,NULL);
|
if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0)
|
||||||
|
{
|
||||||
/* Remove recursively all the directories and files */
|
/* Remove recursively all the directories and files */
|
||||||
for (NumFile = 0;
|
for (NumFile = 0;
|
||||||
NumFile < NumFiles;
|
NumFile < NumFiles;
|
||||||
NumFile++)
|
NumFile++)
|
||||||
if (strcmp (FileList[NumFile]->d_name,".") &&
|
|
||||||
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
|
||||||
{
|
{
|
||||||
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFile]->d_name);
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
Brw_RemoveTree (PathFileRel);
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
|
{
|
||||||
|
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFile]->d_name);
|
||||||
|
Brw_RemoveTree (PathFileRel);
|
||||||
|
}
|
||||||
|
free ((void *) FileList[NumFile]);
|
||||||
}
|
}
|
||||||
|
free ((void *) FileList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||||
|
|
||||||
/***** Remove of new the directory, now empty *****/
|
/***** Remove of new the directory, now empty *****/
|
||||||
if (rmdir (Path))
|
if (rmdir (Path))
|
||||||
|
@ -7462,10 +7490,11 @@ static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTr
|
||||||
struct dirent **FileList;
|
struct dirent **FileList;
|
||||||
bool AdminMarks;
|
bool AdminMarks;
|
||||||
struct MarksProperties Marks;
|
struct MarksProperties Marks;
|
||||||
int NumFileInThisDir;
|
int NumFile;
|
||||||
int NumFilesInThisDir;
|
int NumFiles;
|
||||||
unsigned NumLevls;
|
unsigned NumLevls;
|
||||||
long FilCod; // File code of the file pasted
|
long FilCod; // File code of the file pasted
|
||||||
|
bool CopyIsGoingSuccessful = true;
|
||||||
|
|
||||||
/***** Get the name (only the name) of the origin file or folder *****/
|
/***** Get the name (only the name) of the origin file or folder *****/
|
||||||
Str_SplitFullPathIntoPathAndFileName (PathOrg,
|
Str_SplitFullPathIntoPathAndFileName (PathOrg,
|
||||||
|
@ -7516,116 +7545,138 @@ static bool Brw_PasteTreeIntoFolder (const char *PathOrg,const char *PathDstInTr
|
||||||
Lay_ShowErrorAndExit ("Can not paste unknown file type.");
|
Lay_ShowErrorAndExit ("Can not paste unknown file type.");
|
||||||
}
|
}
|
||||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||||
return false;
|
CopyIsGoingSuccessful = false;
|
||||||
}
|
}
|
||||||
|
else // Quota not exceeded
|
||||||
/***** Copy file or folder *****/
|
|
||||||
if (FileType == Brw_IS_FILE ||
|
|
||||||
FileType == Brw_IS_LINK) // It's a regular file
|
|
||||||
{
|
{
|
||||||
/***** Check if exists the destination file */
|
/***** Copy file or folder *****/
|
||||||
if (Fil_CheckIfPathExists (PathDstWithFile))
|
if (FileType == Brw_IS_FILE ||
|
||||||
{
|
FileType == Brw_IS_LINK) // It's a regular file
|
||||||
sprintf (Gbl.Message,
|
|
||||||
FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_there_is_already_an_object_with_that_name :
|
|
||||||
Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_there_is_already_an_object_with_that_name,
|
|
||||||
FileNameToShow);
|
|
||||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** If the target file browser is that of marks, only HTML files are allowed *****/
|
|
||||||
AdminMarks = Gbl.FileBrowser.Type == Brw_ADMI_MARKS_CRS ||
|
|
||||||
Gbl.FileBrowser.Type == Brw_ADMI_MARKS_GRP;
|
|
||||||
if (AdminMarks)
|
|
||||||
{
|
{
|
||||||
/* Check extension of the file */
|
/***** Check if exists the destination file */
|
||||||
if (Str_FileIsHTML (FileNameOrg))
|
if (Fil_CheckIfPathExists (PathDstWithFile))
|
||||||
Mrk_CheckFileOfMarks (PathOrg,&Marks); // Gbl.Message contains feedback text
|
|
||||||
else
|
|
||||||
{
|
|
||||||
sprintf (Gbl.Message,Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_you_can_not_paste_a_file_here_of_a_type_other_than_HTML,
|
|
||||||
FileNameToShow);
|
|
||||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Update and check the quota before copying the file *****/
|
|
||||||
Gbl.FileBrowser.Size.NumFiles++;
|
|
||||||
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
|
||||||
if (Brw_CheckIfQuotaExceded ())
|
|
||||||
{
|
|
||||||
sprintf (Gbl.Message,FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_disk_quota :
|
|
||||||
Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_it_would_exceed_the_disk_quota,
|
|
||||||
FileNameToShow);
|
|
||||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Quota will not be exceeded ==> copy the origin file to the destination file *****/
|
|
||||||
Fil_FastCopyOfFiles (PathOrg,PathDstWithFile);
|
|
||||||
|
|
||||||
/***** Add entry to the table of files/folders *****/
|
|
||||||
FilCod = Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,FileType,
|
|
||||||
PathDstInTreeWithFile,false,Brw_LICENSE_DEFAULT);
|
|
||||||
if (*FirstFilCod <= 0)
|
|
||||||
*FirstFilCod = FilCod;
|
|
||||||
|
|
||||||
/* Add a new entry of marks into database */
|
|
||||||
if (AdminMarks)
|
|
||||||
Mrk_AddMarksToDB (FilCod,&Marks);
|
|
||||||
|
|
||||||
if (FileType == Brw_IS_FILE)
|
|
||||||
(*NumFilesPasted)++;
|
|
||||||
else // FileType == Brw_IS_LINK
|
|
||||||
(*NumLinksPasted)++;
|
|
||||||
}
|
|
||||||
else if (FileType == Brw_IS_FOLDER) // It's a directory
|
|
||||||
{
|
|
||||||
/***** Scan the source directory *****/
|
|
||||||
NumFilesInThisDir = scandir (PathOrg,&FileList,NULL,alphasort);
|
|
||||||
|
|
||||||
/***** Create the folder in the destination *****/
|
|
||||||
if (!Fil_CheckIfPathExists (PathDstWithFile)) // If already exists, don't overwrite
|
|
||||||
{
|
|
||||||
/* The directory does not exist ==> create it.
|
|
||||||
First, update and check the quota */
|
|
||||||
Gbl.FileBrowser.Size.NumFolds++;
|
|
||||||
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
|
||||||
if (Brw_CheckIfQuotaExceded ())
|
|
||||||
{
|
|
||||||
sprintf (Gbl.Message,Txt_The_copy_has_stopped_when_trying_to_paste_the_folder_X_because_it_would_exceed_the_disk_quota,
|
|
||||||
FileNameToShow);
|
|
||||||
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
/* The quota will not be exceded ==> create the directory */
|
|
||||||
if (mkdir (PathDstWithFile,(mode_t) 0xFFF) != 0)
|
|
||||||
Lay_ShowErrorAndExit ("Can not create folder.");
|
|
||||||
|
|
||||||
/* Add entry to the table of files/folders */
|
|
||||||
Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,FileType,
|
|
||||||
PathDstInTreeWithFile,false,Brw_LICENSE_DEFAULT);
|
|
||||||
}
|
|
||||||
|
|
||||||
/***** Copy each of the files and folders from the origin to the destination *****/
|
|
||||||
for (NumFileInThisDir = 0;
|
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
|
||||||
NumFileInThisDir++)
|
|
||||||
if (strcmp (FileList[NumFileInThisDir]->d_name,".") &&
|
|
||||||
strcmp (FileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
|
||||||
{
|
{
|
||||||
sprintf (PathInFolderOrg,"%s/%s",PathOrg,FileList[NumFileInThisDir]->d_name);
|
sprintf (Gbl.Message,
|
||||||
if (!Brw_PasteTreeIntoFolder (PathInFolderOrg,PathDstInTreeWithFile,
|
FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_there_is_already_an_object_with_that_name :
|
||||||
NumFilesPasted,NumFoldsPasted,NumLinksPasted,
|
Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_there_is_already_an_object_with_that_name,
|
||||||
FirstFilCod))
|
FileNameToShow);
|
||||||
return false;
|
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||||
|
CopyIsGoingSuccessful = false;
|
||||||
}
|
}
|
||||||
|
else // Destination file does not exist
|
||||||
|
{
|
||||||
|
/***** If the target file browser is that of marks, only HTML files are allowed *****/
|
||||||
|
AdminMarks = Gbl.FileBrowser.Type == Brw_ADMI_MARKS_CRS ||
|
||||||
|
Gbl.FileBrowser.Type == Brw_ADMI_MARKS_GRP;
|
||||||
|
if (AdminMarks)
|
||||||
|
{
|
||||||
|
/* Check extension of the file */
|
||||||
|
if (Str_FileIsHTML (FileNameOrg))
|
||||||
|
Mrk_CheckFileOfMarks (PathOrg,&Marks); // Gbl.Message contains feedback text
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sprintf (Gbl.Message,Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_you_can_not_paste_a_file_here_of_a_type_other_than_HTML,
|
||||||
|
FileNameToShow);
|
||||||
|
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||||
|
CopyIsGoingSuccessful = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
(*NumFoldsPasted)++;
|
if (CopyIsGoingSuccessful)
|
||||||
|
{
|
||||||
|
/***** Update and check the quota before copying the file *****/
|
||||||
|
Gbl.FileBrowser.Size.NumFiles++;
|
||||||
|
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
||||||
|
if (Brw_CheckIfQuotaExceded ())
|
||||||
|
{
|
||||||
|
sprintf (Gbl.Message,FileType == Brw_IS_FILE ? Txt_The_copy_has_stopped_when_trying_to_paste_the_file_X_because_it_would_exceed_the_disk_quota :
|
||||||
|
Txt_The_copy_has_stopped_when_trying_to_paste_the_link_X_because_it_would_exceed_the_disk_quota,
|
||||||
|
FileNameToShow);
|
||||||
|
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||||
|
CopyIsGoingSuccessful = false;
|
||||||
|
}
|
||||||
|
else // Quota not exceeded
|
||||||
|
{
|
||||||
|
/***** Quota will not be exceeded ==> copy the origin file to the destination file *****/
|
||||||
|
Fil_FastCopyOfFiles (PathOrg,PathDstWithFile);
|
||||||
|
|
||||||
|
/***** Add entry to the table of files/folders *****/
|
||||||
|
FilCod = Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,FileType,
|
||||||
|
PathDstInTreeWithFile,false,Brw_LICENSE_DEFAULT);
|
||||||
|
if (*FirstFilCod <= 0)
|
||||||
|
*FirstFilCod = FilCod;
|
||||||
|
|
||||||
|
/* Add a new entry of marks into database */
|
||||||
|
if (AdminMarks)
|
||||||
|
Mrk_AddMarksToDB (FilCod,&Marks);
|
||||||
|
|
||||||
|
if (FileType == Brw_IS_FILE)
|
||||||
|
(*NumFilesPasted)++;
|
||||||
|
else // FileType == Brw_IS_LINK
|
||||||
|
(*NumLinksPasted)++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (FileType == Brw_IS_FOLDER) // It's a directory
|
||||||
|
{
|
||||||
|
/***** Scan the source directory *****/
|
||||||
|
if ((NumFiles = scandir (PathOrg,&FileList,NULL,alphasort)) >= 0) // No error
|
||||||
|
{
|
||||||
|
/***** Create the folder in the destination *****/
|
||||||
|
if (!Fil_CheckIfPathExists (PathDstWithFile)) // If already exists, don't overwrite
|
||||||
|
{
|
||||||
|
/* The directory does not exist ==> create it.
|
||||||
|
First, update and check the quota */
|
||||||
|
Gbl.FileBrowser.Size.NumFolds++;
|
||||||
|
Gbl.FileBrowser.Size.TotalSiz += (unsigned long long) FileStatus.st_size;
|
||||||
|
if (Brw_CheckIfQuotaExceded ())
|
||||||
|
{
|
||||||
|
sprintf (Gbl.Message,Txt_The_copy_has_stopped_when_trying_to_paste_the_folder_X_because_it_would_exceed_the_disk_quota,
|
||||||
|
FileNameToShow);
|
||||||
|
Lay_ShowAlert (Lay_WARNING,Gbl.Message);
|
||||||
|
CopyIsGoingSuccessful = false;
|
||||||
|
}
|
||||||
|
else // Quota not exceded
|
||||||
|
{
|
||||||
|
/* Create directory */
|
||||||
|
if (mkdir (PathDstWithFile,(mode_t) 0xFFF) != 0)
|
||||||
|
Lay_ShowErrorAndExit ("Can not create folder.");
|
||||||
|
|
||||||
|
/* Add entry to the table of files/folders */
|
||||||
|
Brw_AddPathToDB (Gbl.Usrs.Me.UsrDat.UsrCod,FileType,
|
||||||
|
PathDstInTreeWithFile,false,Brw_LICENSE_DEFAULT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/***** Copy each of the files and folders from the origin to the destination *****/
|
||||||
|
for (NumFile = 0;
|
||||||
|
NumFile < NumFiles;
|
||||||
|
NumFile++)
|
||||||
|
{
|
||||||
|
if (CopyIsGoingSuccessful &&
|
||||||
|
strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
|
{
|
||||||
|
sprintf (PathInFolderOrg,"%s/%s",PathOrg,FileList[NumFile]->d_name);
|
||||||
|
if (!Brw_PasteTreeIntoFolder (PathInFolderOrg,PathDstInTreeWithFile,
|
||||||
|
NumFilesPasted,NumFoldsPasted,NumLinksPasted,
|
||||||
|
FirstFilCod))
|
||||||
|
CopyIsGoingSuccessful = false;
|
||||||
|
}
|
||||||
|
free ((void *) FileList[NumFile]);
|
||||||
|
}
|
||||||
|
free ((void *) FileList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||||
|
|
||||||
|
if (CopyIsGoingSuccessful)
|
||||||
|
(*NumFoldsPasted)++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
|
return CopyIsGoingSuccessful;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
@ -11310,8 +11361,8 @@ void Brw_RemoveOldFiles (void)
|
||||||
|
|
||||||
static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder)
|
static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder)
|
||||||
{
|
{
|
||||||
extern const char *Txt_Folders_removed;
|
|
||||||
extern const char *Txt_Files_removed;
|
extern const char *Txt_Files_removed;
|
||||||
|
extern const char *Txt_Folders_removed;
|
||||||
|
|
||||||
/***** Remove old files recursively *****/
|
/***** Remove old files recursively *****/
|
||||||
Gbl.FileBrowser.Removed.NumFiles =
|
Gbl.FileBrowser.Removed.NumFiles =
|
||||||
|
@ -11319,9 +11370,10 @@ static void Brw_RemoveOldFilesInBrowser (time_t TimeRemoveFilesOlder)
|
||||||
Brw_ScanDirRemovingOlfFiles (1,Gbl.FileBrowser.Priv.PathRootFolder,TimeRemoveFilesOlder);
|
Brw_ScanDirRemovingOlfFiles (1,Gbl.FileBrowser.Priv.PathRootFolder,TimeRemoveFilesOlder);
|
||||||
|
|
||||||
/***** Success message *****/
|
/***** Success message *****/
|
||||||
sprintf (Gbl.Message,"%s: %u. %s: %u.",
|
sprintf (Gbl.Message,"%s: %u.<br />"
|
||||||
Txt_Folders_removed,Gbl.FileBrowser.Removed.NumFolders,
|
"%s: %u.",
|
||||||
Txt_Files_removed ,Gbl.FileBrowser.Removed.NumFiles);
|
Txt_Files_removed ,Gbl.FileBrowser.Removed.NumFiles,
|
||||||
|
Txt_Folders_removed,Gbl.FileBrowser.Removed.NumFolders);
|
||||||
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
|
Lay_ShowAlert (Lay_SUCCESS,Gbl.Message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11333,71 +11385,74 @@ static void Brw_ScanDirRemovingOlfFiles (unsigned Level,const char *Path,
|
||||||
time_t TimeRemoveFilesOlder)
|
time_t TimeRemoveFilesOlder)
|
||||||
{
|
{
|
||||||
struct dirent **FileList;
|
struct dirent **FileList;
|
||||||
int NumFileInThisDir;
|
int NumFile;
|
||||||
int NumFilesInThisDir;
|
int NumFiles;
|
||||||
char PathFileRel[PATH_MAX+1];
|
char PathFileRel[PATH_MAX+1];
|
||||||
struct stat FileStatus;
|
struct stat FileStatus;
|
||||||
|
|
||||||
/***** Scan directory *****/
|
/***** Scan directory *****/
|
||||||
NumFilesInThisDir = scandir (Path,&FileList,NULL,alphasort);
|
if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
|
||||||
|
|
||||||
if (NumFilesInThisDir > 2)
|
|
||||||
{
|
{
|
||||||
/***** Check file by file removing old files *****/
|
if (NumFiles > 2)
|
||||||
for (NumFileInThisDir = 0;
|
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
|
||||||
NumFileInThisDir++)
|
|
||||||
{
|
{
|
||||||
if (strcmp (FileList[NumFileInThisDir]->d_name,".") &&
|
/***** Check file by file removing old files *****/
|
||||||
strcmp (FileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
for (NumFile = 0;
|
||||||
|
NumFile < NumFiles;
|
||||||
|
NumFile++)
|
||||||
{
|
{
|
||||||
/***** Construct the full path of the file or folder *****/
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFileInThisDir]->d_name);
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
|
|
||||||
/***** Get file or folder status *****/
|
|
||||||
lstat (PathFileRel,&FileStatus);
|
|
||||||
|
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
|
||||||
/* Scan subtree starting at this this directory recursively */
|
|
||||||
Brw_ScanDirRemovingOlfFiles (Level+1,PathFileRel,TimeRemoveFilesOlder);
|
|
||||||
else if (S_ISREG (FileStatus.st_mode) && // It's a regular file
|
|
||||||
FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old
|
|
||||||
{
|
{
|
||||||
/* Remove file */
|
/***** Construct the full path of the file or folder *****/
|
||||||
Lay_ShowAlert (Lay_SUCCESS,PathFileRel);
|
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFile]->d_name);
|
||||||
Gbl.FileBrowser.Removed.NumFiles++;
|
|
||||||
|
/***** Get file or folder status *****/
|
||||||
|
lstat (PathFileRel,&FileStatus);
|
||||||
|
|
||||||
|
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
|
/* Scan subtree starting at this this directory recursively */
|
||||||
|
Brw_ScanDirRemovingOlfFiles (Level + 1,PathFileRel,TimeRemoveFilesOlder);
|
||||||
|
else if (S_ISREG (FileStatus.st_mode) && // It's a regular file
|
||||||
|
FileStatus.st_mtime < TimeRemoveFilesOlder) // ..and it's old
|
||||||
|
{
|
||||||
|
/* Remove file */
|
||||||
|
Lay_ShowAlert (Lay_SUCCESS,PathFileRel);
|
||||||
|
Gbl.FileBrowser.Removed.NumFiles++;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
free ((void *) FileList[NumFile]);
|
||||||
|
}
|
||||||
|
free ((void *) FileList);
|
||||||
|
|
||||||
|
/***** Rescan folder in order to see
|
||||||
|
if it's now empty after deletion *****/
|
||||||
|
if (Level > 1)
|
||||||
|
{
|
||||||
|
/* Count number of files in folder */
|
||||||
|
NumFiles = scandir (Path,&FileList,NULL,alphasort);
|
||||||
|
|
||||||
|
/* Free list of files */
|
||||||
|
for (NumFile = 0;
|
||||||
|
NumFile < NumFiles;
|
||||||
|
NumFile++)
|
||||||
|
free ((void *) FileList[NumFile]);
|
||||||
|
free ((void *) FileList);
|
||||||
}
|
}
|
||||||
free (FileList[NumFileInThisDir]);
|
|
||||||
}
|
}
|
||||||
free (FileList);
|
|
||||||
|
|
||||||
/***** Rescan folder in order to see
|
if (Level > 1 && NumFiles <= 2) // It's an empty folder inside root folder
|
||||||
if it's now empty after deletion *****/
|
|
||||||
if (Level > 1)
|
|
||||||
{
|
{
|
||||||
/* Count number of files in folder */
|
/***** Get folder status *****/
|
||||||
NumFilesInThisDir = scandir (Path,&FileList,NULL,alphasort);
|
lstat (Path,&FileStatus);
|
||||||
|
|
||||||
/* Free list of files */
|
if (FileStatus.st_mtime < TimeRemoveFilesOlder)
|
||||||
for (NumFileInThisDir = 0;
|
{
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
/* Remove folder */
|
||||||
NumFileInThisDir++)
|
Lay_ShowAlert (Lay_SUCCESS,Path);
|
||||||
free (FileList[NumFileInThisDir]);
|
Gbl.FileBrowser.Removed.NumFolders++;
|
||||||
free (FileList);
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Level > 1 && NumFilesInThisDir <= 2) // It's an empty folder inside root folder
|
|
||||||
{
|
|
||||||
/***** Get folder status *****/
|
|
||||||
lstat (Path,&FileStatus);
|
|
||||||
|
|
||||||
if (FileStatus.st_mtime < TimeRemoveFilesOlder)
|
|
||||||
{
|
|
||||||
/* Remove folder */
|
|
||||||
Lay_ShowAlert (Lay_SUCCESS,Path);
|
|
||||||
Gbl.FileBrowser.Removed.NumFolders++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Lay_ShowErrorAndExit ("Error while scanning directory.");
|
||||||
}
|
}
|
||||||
|
|
|
@ -4034,50 +4034,56 @@ int swad__getDirectoryTree (struct soap *soap,
|
||||||
static void Svc_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
static void Svc_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
||||||
{
|
{
|
||||||
extern const char *Txt_NEW_LINE;
|
extern const char *Txt_NEW_LINE;
|
||||||
struct dirent **DirFileList;
|
struct dirent **FileList;
|
||||||
int NumFileInThisDir;
|
int NumFile;
|
||||||
int NumFilesInThisDir;
|
int NumFiles;
|
||||||
char PathFileRel[PATH_MAX+1];
|
char PathFileRel[PATH_MAX+1];
|
||||||
char PathFileInExplTree[PATH_MAX+1];
|
char PathFileInExplTree[PATH_MAX+1];
|
||||||
struct stat FileStatus;
|
struct stat FileStatus;
|
||||||
|
|
||||||
/***** Scan directory *****/
|
/***** Scan directory *****/
|
||||||
NumFilesInThisDir = scandir (Path,&DirFileList,NULL,alphasort);
|
if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
|
||||||
|
{
|
||||||
/***** List files *****/
|
/***** List files *****/
|
||||||
for (NumFileInThisDir = 0;
|
for (NumFile = 0;
|
||||||
NumFileInThisDir < NumFilesInThisDir;
|
NumFile < NumFiles;
|
||||||
NumFileInThisDir++)
|
NumFile++)
|
||||||
if (strcmp (DirFileList[NumFileInThisDir]->d_name,".") &&
|
{
|
||||||
strcmp (DirFileList[NumFileInThisDir]->d_name,"..")) // Skip directories "." and ".."
|
if (strcmp (FileList[NumFile]->d_name,".") &&
|
||||||
{
|
strcmp (FileList[NumFile]->d_name,"..")) // Skip directories "." and ".."
|
||||||
sprintf (PathFileRel ,"%s/%s",Path ,DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
sprintf (PathFileInExplTree,"%s/%s",PathInTree,DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
|
|
||||||
lstat (PathFileRel,&FileStatus);
|
|
||||||
|
|
||||||
/***** Construct the full path of the file or folder *****/
|
|
||||||
Brw_SetFullPathInTree (PathInTree,DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
|
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
|
||||||
{
|
{
|
||||||
/***** Write a row for the subdirectory *****/
|
sprintf (PathFileRel ,"%s/%s",Path ,FileList[NumFile]->d_name);
|
||||||
if (Svc_WriteRowFileBrowser (Level,Brw_IS_FOLDER,DirFileList[NumFileInThisDir]->d_name))
|
sprintf (PathFileInExplTree,"%s/%s",PathInTree,FileList[NumFile]->d_name);
|
||||||
{
|
|
||||||
/* List subtree starting at this this directory */
|
|
||||||
Svc_ListDir (Level+1,PathFileRel,PathFileInExplTree);
|
|
||||||
|
|
||||||
/* Indent and end dir */
|
lstat (PathFileRel,&FileStatus);
|
||||||
Svc_IndentXMLLine (Level);
|
|
||||||
fprintf (Gbl.F.XML,"</dir>%s",Txt_NEW_LINE);
|
/***** Construct the full path of the file or folder *****/
|
||||||
|
Brw_SetFullPathInTree (PathInTree,FileList[NumFile]->d_name);
|
||||||
|
|
||||||
|
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
|
{
|
||||||
|
/***** Write a row for the subdirectory *****/
|
||||||
|
if (Svc_WriteRowFileBrowser (Level,Brw_IS_FOLDER,FileList[NumFile]->d_name))
|
||||||
|
{
|
||||||
|
/* List subtree starting at this this directory */
|
||||||
|
Svc_ListDir (Level + 1,PathFileRel,PathFileInExplTree);
|
||||||
|
|
||||||
|
/* Indent and end dir */
|
||||||
|
Svc_IndentXMLLine (Level);
|
||||||
|
fprintf (Gbl.F.XML,"</dir>%s",Txt_NEW_LINE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
||||||
|
Svc_WriteRowFileBrowser (Level,
|
||||||
|
Str_FileIs (FileList[NumFile]->d_name,"url") ? Brw_IS_LINK :
|
||||||
|
Brw_IS_FILE,
|
||||||
|
FileList[NumFile]->d_name);
|
||||||
}
|
}
|
||||||
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
|
||||||
Svc_WriteRowFileBrowser (Level,
|
free ((void *) FileList[NumFile]);
|
||||||
Str_FileIs (DirFileList[NumFileInThisDir]->d_name,"url") ? Brw_IS_LINK :
|
|
||||||
Brw_IS_FILE,
|
|
||||||
DirFileList[NumFileInThisDir]->d_name);
|
|
||||||
}
|
}
|
||||||
|
free ((void *) FileList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
Loading…
Reference in New Issue