X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cde%2Fprograms%2Fdtcreate%2Ffileio.c;h=ccb637511193696d2520a3271087dd5d6c2009b5;hb=1fe5a550b25493541cf9dfb21bbf2f8eaf7ebcd4;hp=ff9e47793d49968b7c2b6bed4ab5523fc53a416d;hpb=83b6996daa2c5ae22fc2b69093814cb08314954a;p=oweals%2Fcde.git diff --git a/cde/programs/dtcreate/fileio.c b/cde/programs/dtcreate/fileio.c index ff9e4779..ccb63751 100644 --- a/cde/programs/dtcreate/fileio.c +++ b/cde/programs/dtcreate/fileio.c @@ -1,7 +1,31 @@ +/* + * CDE - Common Desktop Environment + * + * Copyright (c) 1993-2012, The Open Group. All rights reserved. + * + * These libraries and programs are free software; you can + * redistribute them and/or modify them under the terms of the GNU + * Lesser General Public License as published by the Free Software + * Foundation; either version 2 of the License, or (at your option) + * any later version. + * + * These libraries and programs are distributed in the hope that + * they will be useful, but WITHOUT ANY WARRANTY; without even the + * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with these libraries and programs; if not, write + * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth + * Floor, Boston, MA 02110-1301 USA + */ #include #include #include +#include #include +#include #include
@@ -9,6 +33,8 @@ #include "dtcreate.h" #include "cmnrtns.h" #include "fileio.h" +#include "parser.h" +#include "ErrorDialog.h" #define COMMENT_CHAR '#' #define MAX_KEY 10000 @@ -386,6 +412,9 @@ ushort WriteDefinitionFile(char *pszFile, ActionData *pAD) char *ptr; char *msgPtr, *fmtPtr, *errPtr; + if (!pszFile) + return 1; + /***************************************************************************/ /* Open action and filetypes definition file for writing. */ /***************************************************************************/ @@ -587,8 +616,11 @@ ushort WriteDefinitionFile(char *pszFile, ActionData *pAD) } } SetCookie(fp); - if (fp) fclose(fp); + if (fp) + fclose(fp); + chmod(pszFile, 0644); + return(0); } @@ -629,7 +661,7 @@ ushort WriteActionFile(ActionData *pAD) /***************************************************************************/ /* Open action file for writing. */ /***************************************************************************/ - if (pszFile && (fp = fopen(pszFile, "w")) == NULL) { + if (pszFile == NULL || (fp = fopen(pszFile, "w")) == NULL) { #ifdef DEBUG printf("Can not open file.\n"); /* debug */ #endif @@ -668,7 +700,7 @@ ushort WriteActionFile(ActionData *pAD) fprintf(fp, "echo \"Common Desktop Environment Dt action\"\n"); fprintf(fp, "\n"); - if (fp) fclose(fp); + fclose(fp); chmod(pszFile, 0755); return(0); } @@ -720,7 +752,7 @@ int OpenDefinitionFile(char *pszFile, ActionData *pAD) { FILE *fp = (FILE *)NULL; - int rc; + int rc = 1; char *msgPtr, *fmtPtr, *errPtr; /***************************************************************************/ @@ -763,10 +795,11 @@ int OpenDefinitionFile(char *pszFile, ActionData *pAD) sprintf(errPtr, fmtPtr, msgPtr, pszFile); display_error_message(CreateActionAppShell, errPtr); XtFree(errPtr); + fclose(fp); return(1); } } - if (fp) fclose(fp); + fclose(fp); return(rc); } @@ -814,9 +847,14 @@ char * CreateIconName(char *pszDirName, char *pszBaseName, enum icon_size_range case Medium_Icon : strcpy(pszSize, MEDIUM_EXT); break; + case Small_Icon : + strcpy(pszSize, SMALL_EXT); + break; case Tiny_Icon : strcpy(pszSize, TINY_EXT); break; + case None_Selected : + pszSize[0] = 0; } if (bIsMask) { strcat(pszSize, "_m");