mirror of
https://github.com/acanas/swad-core.git
synced 2024-06-01 06:15:31 +02:00
Version 16.111.9
This commit is contained in:
parent
efd20a9e58
commit
9d4de6d57a
|
@ -189,13 +189,14 @@
|
||||||
/****************************** Public constants *****************************/
|
/****************************** Public constants *****************************/
|
||||||
/*****************************************************************************/
|
/*****************************************************************************/
|
||||||
|
|
||||||
#define Log_PLATFORM_VERSION "SWAD 16.111.8 (2016-12-28)"
|
#define Log_PLATFORM_VERSION "SWAD 16.111.9 (2016-12-29)"
|
||||||
#define CSS_FILE "swad16.111.5.css"
|
#define CSS_FILE "swad16.111.5.css"
|
||||||
#define JS_FILE "swad16.101.js"
|
#define JS_FILE "swad16.101.js"
|
||||||
|
|
||||||
// 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 16.111.9: Dec 29, 2016 Fixed bugs in lstat, reported by Coverity. (211138 lines)
|
||||||
Version 16.111.8: Dec 28, 2016 Fixed bug in notifications, reported by Coverity. (211119 lines)
|
Version 16.111.8: Dec 28, 2016 Fixed bug in notifications, reported by Coverity. (211119 lines)
|
||||||
Version 16.111.7: Dec 28, 2016 Fixed minor bug in groups, reported by Coverity. (211114 lines)
|
Version 16.111.7: Dec 28, 2016 Fixed minor bug in groups, reported by Coverity. (211114 lines)
|
||||||
Version 16.111.6: Dec 28, 2016 Fixed bug in assigments, reported by Coverity. (211109 lines)
|
Version 16.111.6: Dec 28, 2016 Fixed bug in assigments, reported by Coverity. (211109 lines)
|
||||||
|
|
10
swad_file.c
10
swad_file.c
|
@ -440,8 +440,9 @@ void Fil_RemoveTree (const char *Path)
|
||||||
|
|
||||||
if (Fil_CheckIfPathExists (Path))
|
if (Fil_CheckIfPathExists (Path))
|
||||||
{
|
{
|
||||||
lstat (Path,&FileStatus);
|
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
{
|
{
|
||||||
if (rmdir (Path))
|
if (rmdir (Path))
|
||||||
{
|
{
|
||||||
|
@ -501,8 +502,9 @@ void Fil_RemoveOldTmpFiles (const char *Path,time_t TimeToRemove,bool RemoveDire
|
||||||
char Path2[PATH_MAX+1];
|
char Path2[PATH_MAX+1];
|
||||||
struct stat FileStatus;
|
struct stat FileStatus;
|
||||||
|
|
||||||
lstat (Path,&FileStatus);
|
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
{
|
{
|
||||||
/***** Scan the directory *****/
|
/***** Scan the directory *****/
|
||||||
if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error
|
if ((NumFiles = scandir (Path,&FileList,NULL,NULL)) >= 0) // No error
|
||||||
|
|
|
@ -4983,8 +4983,9 @@ static void Brw_CalcSizeOfDirRecursive (unsigned Level,char *Path)
|
||||||
|
|
||||||
/* 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[NumFile]->d_name);
|
sprintf (PathFileRel,"%s/%s",Path,FileList[NumFile]->d_name);
|
||||||
lstat (PathFileRel,&FileStatus);
|
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else 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;
|
||||||
|
@ -5038,8 +5039,9 @@ static void Brw_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
||||||
Brw_SetFullPathInTree (PathInTree,FileList[NumFile]->d_name);
|
Brw_SetFullPathInTree (PathInTree,FileList[NumFile]->d_name);
|
||||||
|
|
||||||
/***** Get file or folder status *****/
|
/***** Get file or folder status *****/
|
||||||
lstat (PathFileRel,&FileStatus);
|
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
{
|
{
|
||||||
if (Gbl.FileBrowser.FullTree)
|
if (Gbl.FileBrowser.FullTree)
|
||||||
ExpandTree = Brw_EXPAND_TREE_NOTHING;
|
ExpandTree = Brw_EXPAND_TREE_NOTHING;
|
||||||
|
@ -6206,8 +6208,9 @@ void Brw_RemFileFromTree (void)
|
||||||
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
|
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
|
||||||
|
|
||||||
/***** Check if is a file/link or a folder *****/
|
/***** Check if is a file/link or a folder *****/
|
||||||
lstat (Path,&FileStatus);
|
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||||
if (S_ISREG (FileStatus.st_mode)) // It's a file or a link
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISREG (FileStatus.st_mode)) // It's a file or a link
|
||||||
{
|
{
|
||||||
/* Name of the file/link to be shown */
|
/* Name of the file/link to be shown */
|
||||||
Brw_LimitLengthFileNameToShow (Str_FileIs (Gbl.FileBrowser.FilFolLnkName,"url") ? Brw_IS_LINK :
|
Brw_LimitLengthFileNameToShow (Str_FileIs (Gbl.FileBrowser.FilFolLnkName,"url") ? Brw_IS_LINK :
|
||||||
|
@ -6256,8 +6259,9 @@ void Brw_RemFolderFromTree (void)
|
||||||
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
|
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,Gbl.FileBrowser.Priv.FullPathInTree);
|
||||||
|
|
||||||
/***** Check if it's a file or a folder *****/
|
/***** Check if it's a file or a folder *****/
|
||||||
lstat (Path,&FileStatus);
|
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
if (Brw_RemoveFolderFromDiskAndDB (Path,
|
if (Brw_RemoveFolderFromDiskAndDB (Path,
|
||||||
Gbl.FileBrowser.Priv.FullPathInTree))
|
Gbl.FileBrowser.Priv.FullPathInTree))
|
||||||
{
|
{
|
||||||
|
@ -7631,14 +7635,14 @@ static bool Brw_PasteTreeIntoFolder (unsigned LevelOrg,
|
||||||
FileNameOrg);
|
FileNameOrg);
|
||||||
|
|
||||||
/***** Is it a file or a folder? *****/
|
/***** Is it a file or a folder? *****/
|
||||||
lstat (PathOrg,&FileStatus);
|
FileType = Brw_IS_UNKNOWN;
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
if (lstat (PathOrg,&FileStatus)) // On success ==> 0 is returned
|
||||||
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
FileType = Brw_IS_FOLDER;
|
FileType = Brw_IS_FOLDER;
|
||||||
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
||||||
FileType = Str_FileIs (FileNameOrg,"url") ? Brw_IS_LINK : // It's a link (URL inside a .url file)
|
FileType = Str_FileIs (FileNameOrg,"url") ? Brw_IS_LINK : // It's a link (URL inside a .url file)
|
||||||
Brw_IS_FILE; // It's a file
|
Brw_IS_FILE; // It's a file
|
||||||
else
|
|
||||||
FileType = Brw_IS_UNKNOWN;
|
|
||||||
|
|
||||||
/***** Name of the file/folder/link to be shown ****/
|
/***** Name of the file/folder/link to be shown ****/
|
||||||
Brw_LimitLengthFileNameToShow (FileType,FileNameOrg,FileNameToShow);
|
Brw_LimitLengthFileNameToShow (FileType,FileNameOrg,FileNameToShow);
|
||||||
|
@ -10166,7 +10170,7 @@ bool Brw_GetFileTypeSizeAndDate (struct FileMetadata *FileMetadata)
|
||||||
|
|
||||||
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,
|
sprintf (Path,"%s/%s",Gbl.FileBrowser.Priv.PathAboveRootFolder,
|
||||||
FileMetadata->FullPathInTree);
|
FileMetadata->FullPathInTree);
|
||||||
if (lstat (Path,&FileStatus))
|
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||||
{
|
{
|
||||||
// Error on lstat
|
// Error on lstat
|
||||||
FileMetadata->FileType = Brw_IS_UNKNOWN;
|
FileMetadata->FileType = Brw_IS_UNKNOWN;
|
||||||
|
@ -11681,10 +11685,10 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path,
|
||||||
/***** Save folder status *****/
|
/***** Save folder status *****/
|
||||||
// Folder st_mtime must be saved before remove files inside it
|
// Folder st_mtime must be saved before remove files inside it
|
||||||
// because st_mtime is updated by the deletion
|
// because st_mtime is updated by the deletion
|
||||||
lstat (Path,&FolderStatus);
|
if (lstat (Path,&FileStatus)) // On success ==> 0 is returned
|
||||||
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
/***** Scan directory *****/
|
/***** Scan directory *****/
|
||||||
if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
|
else if ((NumFiles = scandir (Path,&FileList,NULL,alphasort)) >= 0) // No error
|
||||||
{
|
{
|
||||||
/***** Check file by file removing old files *****/
|
/***** Check file by file removing old files *****/
|
||||||
for (NumFile = 0;
|
for (NumFile = 0;
|
||||||
|
@ -11699,8 +11703,9 @@ static void Brw_ScanDirRemovingOldFiles (unsigned Level,const char *Path,
|
||||||
sprintf (PathFileInExplTree,"%s/%s",PathInTree,FileList[NumFile]->d_name);
|
sprintf (PathFileInExplTree,"%s/%s",PathInTree,FileList[NumFile]->d_name);
|
||||||
|
|
||||||
/***** Get file or folder status *****/
|
/***** Get file or folder status *****/
|
||||||
lstat (PathFileRel,&FileStatus);
|
if (lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a folder
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISDIR (FileStatus.st_mode)) // It's a folder
|
||||||
/* Scan subtree starting at this this directory recursively */
|
/* Scan subtree starting at this this directory recursively */
|
||||||
Brw_ScanDirRemovingOldFiles (Level + 1,PathFileRel,
|
Brw_ScanDirRemovingOldFiles (Level + 1,PathFileRel,
|
||||||
PathFileInExplTree,
|
PathFileInExplTree,
|
||||||
|
|
|
@ -4386,29 +4386,30 @@ static void Svc_ListDir (unsigned Level,const char *Path,const char *PathInTree)
|
||||||
sprintf (PathFileRel ,"%s/%s",Path ,FileList[NumFile]->d_name);
|
sprintf (PathFileRel ,"%s/%s",Path ,FileList[NumFile]->d_name);
|
||||||
sprintf (PathFileInExplTree,"%s/%s",PathInTree,FileList[NumFile]->d_name);
|
sprintf (PathFileInExplTree,"%s/%s",PathInTree,FileList[NumFile]->d_name);
|
||||||
|
|
||||||
lstat (PathFileRel,&FileStatus);
|
if (!lstat (PathFileRel,&FileStatus)) // On success ==> 0 is returned
|
||||||
|
|
||||||
/***** 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 *****/
|
/***** Construct the full path of the file or folder *****/
|
||||||
if (Svc_WriteRowFileBrowser (Level,Brw_IS_FOLDER,FileList[NumFile]->d_name))
|
Brw_SetFullPathInTree (PathInTree,FileList[NumFile]->d_name);
|
||||||
{
|
|
||||||
/* List subtree starting at this this directory */
|
|
||||||
Svc_ListDir (Level + 1,PathFileRel,PathFileInExplTree);
|
|
||||||
|
|
||||||
/* Indent and end dir */
|
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
Svc_IndentXMLLine (Level);
|
{
|
||||||
fprintf (Gbl.F.XML,"</dir>%s",Txt_NEW_LINE);
|
/***** 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,
|
|
||||||
Str_FileIs (FileList[NumFile]->d_name,"url") ? Brw_IS_LINK :
|
|
||||||
Brw_IS_FILE,
|
|
||||||
FileList[NumFile]->d_name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
free ((void *) FileList[NumFile]);
|
free ((void *) FileList[NumFile]);
|
||||||
|
|
58
swad_zip.c
58
swad_zip.c
|
@ -229,18 +229,21 @@ void ZIP_CreateZIPAsgWrk (void)
|
||||||
if (Result == 0)
|
if (Result == 0)
|
||||||
{
|
{
|
||||||
/***** Get file size *****/
|
/***** Get file size *****/
|
||||||
lstat (PathFileZIP,&FileStatus);
|
if (lstat (PathFileZIP,&FileStatus)) // On success ==> 0 is returned
|
||||||
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/***** Create URL pointing to ZIP file *****/
|
||||||
|
sprintf (URLWithSpaces,"%s/%s/%s/%s",
|
||||||
|
Cfg_URL_SWAD_PUBLIC,
|
||||||
|
Cfg_FOLDER_FILE_BROWSER_TMP,
|
||||||
|
Gbl.FileBrowser.TmpPubDir,
|
||||||
|
FileNameZIP);
|
||||||
|
Str_CopyStrChangingSpaces (URLWithSpaces,URL,PATH_MAX); // In HTML, URL must have no spaces
|
||||||
|
|
||||||
/***** Create URL pointing to ZIP file *****/
|
/****** Link to download file *****/
|
||||||
sprintf (URLWithSpaces,"%s/%s/%s/%s",
|
ZIP_ShowLinkToDownloadZIP (FileNameZIP,URL,FileStatus.st_size,0);
|
||||||
Cfg_URL_SWAD_PUBLIC,
|
}
|
||||||
Cfg_FOLDER_FILE_BROWSER_TMP,
|
|
||||||
Gbl.FileBrowser.TmpPubDir,
|
|
||||||
FileNameZIP);
|
|
||||||
Str_CopyStrChangingSpaces (URLWithSpaces,URL,PATH_MAX); // In HTML, URL must have no spaces
|
|
||||||
|
|
||||||
/****** Link to download file *****/
|
|
||||||
ZIP_ShowLinkToDownloadZIP (FileNameZIP,URL,FileStatus.st_size,0);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Lay_ShowErrorAndExit ("Can not compress files into zip file.");
|
Lay_ShowErrorAndExit ("Can not compress files into zip file.");
|
||||||
|
@ -456,18 +459,21 @@ static void ZIP_CompressFolderIntoZIP (void)
|
||||||
if (Result == 0)
|
if (Result == 0)
|
||||||
{
|
{
|
||||||
/***** Get file size *****/
|
/***** Get file size *****/
|
||||||
lstat (PathFileZIP,&FileStatus);
|
if (lstat (PathFileZIP,&FileStatus)) // On success ==> 0 is returned
|
||||||
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/***** Create URL pointing to ZIP file *****/
|
||||||
|
sprintf (URLWithSpaces,"%s/%s/%s/%s",
|
||||||
|
Cfg_URL_SWAD_PUBLIC,
|
||||||
|
Cfg_FOLDER_FILE_BROWSER_TMP,
|
||||||
|
Gbl.FileBrowser.TmpPubDir,
|
||||||
|
FileNameZIP);
|
||||||
|
Str_CopyStrChangingSpaces (URLWithSpaces,URL,PATH_MAX); // In HTML, URL must have no spaces
|
||||||
|
|
||||||
/***** Create URL pointing to ZIP file *****/
|
/****** Link to download file *****/
|
||||||
sprintf (URLWithSpaces,"%s/%s/%s/%s",
|
ZIP_ShowLinkToDownloadZIP (FileNameZIP,URL,FileStatus.st_size,UncompressedSize);
|
||||||
Cfg_URL_SWAD_PUBLIC,
|
}
|
||||||
Cfg_FOLDER_FILE_BROWSER_TMP,
|
|
||||||
Gbl.FileBrowser.TmpPubDir,
|
|
||||||
FileNameZIP);
|
|
||||||
Str_CopyStrChangingSpaces (URLWithSpaces,URL,PATH_MAX); // In HTML, URL must have no spaces
|
|
||||||
|
|
||||||
/****** Link to download file *****/
|
|
||||||
ZIP_ShowLinkToDownloadZIP (FileNameZIP,URL,FileStatus.st_size,UncompressedSize);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Lay_ShowErrorAndExit ("Can not compress files into zip file.");
|
Lay_ShowErrorAndExit ("Can not compress files into zip file.");
|
||||||
|
@ -533,14 +539,14 @@ static unsigned long long ZIP_CloneDir (const char *Path,const char *PathClone,c
|
||||||
sprintf (PathFileClone,"%s/%s",
|
sprintf (PathFileClone,"%s/%s",
|
||||||
PathClone,FileList[NumFile]->d_name);
|
PathClone,FileList[NumFile]->d_name);
|
||||||
|
|
||||||
lstat (PathFile,&FileStatus);
|
FileType = Brw_IS_UNKNOWN;
|
||||||
if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
if (lstat (PathFile,&FileStatus)) // On success ==> 0 is returned
|
||||||
|
Lay_ShowErrorAndExit ("Can not get information about a file or folder.");
|
||||||
|
else if (S_ISDIR (FileStatus.st_mode)) // It's a directory
|
||||||
FileType = Brw_IS_FOLDER;
|
FileType = Brw_IS_FOLDER;
|
||||||
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
else if (S_ISREG (FileStatus.st_mode)) // It's a regular file
|
||||||
FileType = Str_FileIs (FileList[NumFile]->d_name,"url") ? Brw_IS_LINK : // It's a link (URL inside a .url file)
|
FileType = Str_FileIs (FileList[NumFile]->d_name,"url") ? Brw_IS_LINK : // It's a link (URL inside a .url file)
|
||||||
Brw_IS_FILE; // It's a file
|
Brw_IS_FILE; // It's a file
|
||||||
else
|
|
||||||
FileType = Brw_IS_UNKNOWN;
|
|
||||||
|
|
||||||
Hidden = (SeeDocsZone || SeeMarks) ? Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (FileType,PathFileInTree) :
|
Hidden = (SeeDocsZone || SeeMarks) ? Brw_CheckIfFileOrFolderIsSetAsHiddenInDB (FileType,PathFileInTree) :
|
||||||
false;
|
false;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user