~ubuntu-branches/ubuntu/maverick/notecase/maverick

« back to all changes in this revision

Viewing changes to src/lib/NoteDocument.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Mitsuya Shibata
  • Date: 2008-02-10 09:56:36 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20080210095636-n7dpodksxxxjrrar
Tags: 1.7.9-0ubuntu1
* New Upstream Release (LP: #190582)
* Keboard shortcuts already work in previous version (LP: #137466)
* Node Title Bar function  already work too (LP: #185985)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#include "../support.h"
30
30
 
31
31
#include <gtk/gtk.h>
 
32
#include <glib.h>
 
33
#include <glib/gstdio.h>
 
34
 
32
35
int gtkMessageBox(const char *szText, int nButtons = GTK_BUTTONS_OK, int nIcon = GTK_MESSAGE_INFO); //TOFIX temp
33
36
int cmpver(const char* szVer1, const char* szVer2);
34
37
 
166
169
#endif
167
170
 
168
171
        //check if file exists
169
 
        if(0 != access(szPath, 0))
 
172
        if(0 != g_access(szPath, 0))
170
173
                return DOC_LOAD_NOT_FOUND;
171
174
 
172
175
        //test if file readable
173
 
        if(0 != access(szPath, 04))
 
176
        if(0 != g_access(szPath, 04))
174
177
                return DOC_LOAD_PERMISSIONS;
175
178
 
176
179
        //TOFIX special factory fn.
403
406
        // - this is good to preserve file data in case Notecase crashes while saving
404
407
 
405
408
        bool bTwoStepSave = false;
406
 
        if(0 == access(szPath, 0))
 
409
        if(0 == g_access(szPath, 0))
407
410
                bTwoStepSave = true;
408
411
 
409
412
        std::string strTargetPath(szPath);
414
417
        {
415
418
                //quick FIX: delete file if it already exists
416
419
                //TOFIX more precise fix would be to test/fix file open flags when saving
417
 
        #ifdef _WIN32
418
 
                ::DeleteFile(szPath);
419
 
        #else
420
 
                remove(szPath);
421
 
        #endif
 
420
                g_remove(szPath);
422
421
        }
423
422
 
424
423
        if(FORMAT_NOTECASE_HTML == nFormat)
534
533
                                sprintf(szPathBak, "%s.bak%d", szPath, nBakIdx);
535
534
 
536
535
                                //rename .bak file if already exists
537
 
                                #ifdef _WIN32
538
 
                                        ::DeleteFile(szPathBak);
539
 
                                #else
540
 
                                        remove(szPathBak);
541
 
                                #endif
 
536
                                g_remove(szPathBak);
542
537
 
543
538
                                //then rename existing file as .bak (to make room for new file)
544
 
                        #ifdef _WIN32
545
 
                                bool bRes = (FALSE != ::MoveFile(szPath, szPathBak));
546
 
                        #else
547
 
                                bool bRes = (0 == rename(szPath, szPathBak));
548
 
                        #endif
 
539
                                bool bRes = (0 == g_rename(szPath, szPathBak));
549
540
                                if(!bRes)
550
541
                                {
551
542
                                        //error creating backup file
552
543
                                        ASSERT(FALSE);
553
 
                                        #ifdef _WIN32
554
 
                                                ::DeleteFile(szPath);
555
 
                                        #else
556
 
                                                remove(szPath);
557
 
                                        #endif
 
544
                                        g_remove(szPath);
558
545
                                }
559
546
                        }
560
547
                        else
561
548
                        {
562
549
                                //quick FIX: delete target file if it already exists
563
550
                                //TOFIX more precise fix would be to test/fix file open flags when saving
564
 
                        #ifdef _WIN32
565
 
                                ::DeleteFile(szPath);
566
 
                        #else
567
 
                                remove(szPath);
568
 
                        #endif
 
551
                                g_remove(szPath);
569
552
                        }
570
553
 
571
554
                        //move temporary file to target path
572
 
                #ifdef _WIN32
573
 
                        bool bRes = (FALSE != ::MoveFile(strTargetPath.c_str(), szPath));
574
 
                #else
575
 
                        bool bRes = (0 == rename(strTargetPath.c_str(), szPath));
576
 
                #endif
 
555
                        bool bRes = (0 == g_rename(strTargetPath.c_str(), szPath));
577
556
                        if(!bRes)
578
557
                                return DOC_SAVE_ERR_OVERWRITE; // Failed to owerwrite target file
579
558
                }