~ubuntu-branches/ubuntu/saucy/nspr/saucy-updates

« back to all changes in this revision

Viewing changes to mozilla/nsprpub/pr/tests/testfile.c

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2009-08-10 11:34:26 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20090810113426-3uv4diflrkcbdimm
Tags: 4.8-0ubuntu1
* New upstream release: 4.8 (LP: #387812)
* adjust patches to changed upstreanm codebase
  - update debian/patches/99_configure.patch
* update shlibs symbols to include new API elements
  - update debian/libnspr4-0d.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
#if defined(_PR_PTHREADS) && !defined(_PR_DCETHREADS)
49
49
#include <pthread.h>
50
50
#endif
 
51
#ifdef SYMBIAN
 
52
#include <getopt.h>
 
53
#endif
51
54
 
52
55
#if defined(XP_OS2)
53
56
#define INCL_DOSFILEMGR
58
61
 
59
62
static int _debug_on = 0;
60
63
 
61
 
#ifdef XP_MAC
62
 
#include "prlog.h"
63
 
#include "primpl.h"
64
 
#define printf PR_LogPrint
 
64
#ifdef WINCE
65
65
#define setbuf(x,y)
66
 
extern void SetupMacPrintfLog(char *logFile);
67
66
#endif
68
67
 
69
68
#ifdef XP_WIN
107
106
char *FILE_NAME = "pr_testfile";
108
107
char *HIDDEN_FILE_NAME = "hidden_pr_testfile";
109
108
#else
 
109
#ifdef SYMBIAN
 
110
char *TEST_DIR = "c:\\data\\testfile_dir";
 
111
#else
110
112
char *TEST_DIR = "/tmp/testfile_dir";
 
113
#endif
111
114
char *FILE_NAME = "pr_testfile";
112
115
char *HIDDEN_FILE_NAME = ".hidden_pr_testfile";
113
116
#endif
114
117
buffer *in_buf, *out_buf;
115
118
char pathname[256], renamename[256];
 
119
#ifdef WINCE
 
120
WCHAR wPathname[256];
 
121
#endif
116
122
#define TMPDIR_LEN      64
117
123
char testdir[TMPDIR_LEN];
118
124
static PRInt32 PR_CALLBACK DirTest(void *argunused);
673
679
                }
674
680
        PR_Close(fd_file);
675
681
        }
676
 
#if defined(XP_UNIX) || defined(XP_MAC) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
 
682
#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
677
683
        /*
678
684
         * Create a hidden file - a platform-dependent operation
679
685
         */
680
686
        strcpy(pathname, TEST_DIR);
681
687
        strcat(pathname, "/");
682
688
        strcat(pathname, HIDDEN_FILE_NAME);
683
 
#if defined(XP_UNIX) || defined(XP_MAC) || defined(XP_BEOS)
 
689
#if defined(XP_UNIX) || defined(XP_BEOS)
684
690
        DPRINTF(("Creating hidden test file %s\n",pathname));
685
691
        fd_file = PR_Open(pathname, PR_RDWR | PR_CREATE_FILE, 0777);
686
692
 
691
697
                return -1;
692
698
        }
693
699
 
694
 
#if defined(XP_MAC)
695
 
        {
696
 
#include <files.h>
697
 
 
698
 
        OSErr                   err;
699
 
        FCBPBRec                fcbpb;
700
 
        CInfoPBRec              pb;
701
 
        Str255                  pascalMacPath;
702
 
 
703
 
        fcbpb.ioNamePtr = pascalMacPath;
704
 
        fcbpb.ioVRefNum = 0;
705
 
        fcbpb.ioRefNum = fd_file->secret->md.osfd;
706
 
        fcbpb.ioFCBIndx = 0;
707
 
        
708
 
        err = PBGetFCBInfoSync(&fcbpb);
709
 
        if (err != noErr) {
710
 
        PR_Close(fd_file);
711
 
        return -1;
712
 
        }
713
 
        
714
 
        pb.hFileInfo.ioNamePtr = pascalMacPath;
715
 
        pb.hFileInfo.ioVRefNum = fcbpb.ioFCBVRefNum;
716
 
        pb.hFileInfo.ioDirID = fcbpb.ioFCBParID;
717
 
        pb.hFileInfo.ioFDirIndex = 0;
718
 
        
719
 
        err = PBGetCatInfoSync(&pb);
720
 
        if (err != noErr) {
721
 
        PR_Close(fd_file);
722
 
        return -1;
723
 
        }
724
 
 
725
 
        pb.hFileInfo.ioNamePtr = pascalMacPath;
726
 
        pb.hFileInfo.ioVRefNum = fcbpb.ioFCBVRefNum;
727
 
        pb.hFileInfo.ioDirID = fcbpb.ioFCBParID;
728
 
        pb.hFileInfo.ioFDirIndex = 0;
729
 
        
730
 
        pb.hFileInfo.ioFlFndrInfo.fdFlags |= fInvisible;
731
 
 
732
 
        err = PBSetCatInfoSync(&pb);
733
 
        if (err != noErr) {
734
 
        PR_Close(fd_file);
735
 
        return -1;
736
 
        }
737
 
 
738
 
        }
739
 
#endif
740
 
 
741
700
    PR_Close(fd_file);
742
701
 
743
 
        
 
702
#elif defined(WINCE)
 
703
        DPRINTF(("Creating hidden test file %s\n",pathname));
 
704
    MultiByteToWideChar(CP_ACP, 0, pathname, -1, wPathname, 256); 
 
705
        hfile = CreateFile(wPathname, GENERIC_READ,
 
706
                                                FILE_SHARE_READ|FILE_SHARE_WRITE,
 
707
                                                NULL,
 
708
                                                CREATE_NEW,
 
709
                                                FILE_ATTRIBUTE_HIDDEN,
 
710
                                                NULL);
 
711
        if (hfile == INVALID_HANDLE_VALUE) {
 
712
                printf("testfile failed to create/open hidden file %s [0, %d]\n",
 
713
                                pathname, GetLastError());
 
714
                return -1;
 
715
        }
 
716
        CloseHandle(hfile);
 
717
                                                
744
718
#elif defined(XP_PC) && defined(WIN32)
745
719
        DPRINTF(("Creating hidden test file %s\n",pathname));
746
720
        hfile = CreateFile(pathname, GENERIC_READ,
766
740
                return -1;
767
741
        }
768
742
        PR_Close(fd_file);
769
 
#endif  /* XP _UNIX || XP_MAC*/
 
743
#endif  /* XP_UNIX */
770
744
 
771
 
#endif  /* XP_UNIX || XP_MAC ||(XP_PC && WIN32) */
 
745
#endif  /* XP_UNIX || (XP_PC && WIN32) */
772
746
 
773
747
 
774
748
        if (PR_FAILURE == PR_CloseDir(fd_dir))
790
764
         * List all files, including hidden files
791
765
         */
792
766
        DPRINTF(("Listing all files in directory %s\n",TEST_DIR));
793
 
#if defined(XP_UNIX) || defined(XP_MAC) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
 
767
#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
794
768
        num_files = FILES_IN_DIR + 1;
795
769
#else
796
770
        num_files = FILES_IN_DIR;
826
800
 
827
801
    PR_CloseDir(fd_dir);
828
802
 
829
 
#if defined(XP_UNIX) || defined(XP_MAC) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
 
803
#if defined(XP_UNIX) || (defined(XP_PC) && defined(WIN32)) || defined(XP_OS2) || defined(XP_BEOS)
830
804
 
831
805
        /*
832
806
         * List all files, except hidden files
863
837
        }
864
838
 
865
839
    PR_CloseDir(fd_dir);
866
 
#endif  /* XP_UNIX || XP_MAC || (XP_PC && WIN32) */
 
840
#endif  /* XP_UNIX || (XP_PC && WIN32) */
867
841
 
868
842
        strcpy(renamename, TEST_DIR);
869
843
        strcat(renamename, ".RENAMED");
970
944
        PR_Init(PR_USER_THREAD, PR_PRIORITY_NORMAL, 0);
971
945
    PR_STDIO_INIT();
972
946
 
973
 
#ifdef XP_MAC
974
 
        SetupMacPrintfLog("testfile.log");
975
 
#endif
976
 
 
977
947
        mon = PR_NewMonitor();
978
948
        if (mon == NULL) {
979
949
                printf("testfile: PR_NewMonitor failed\n");
980
950
                exit(2);
981
951
        }
982
952
#ifdef WIN32
 
953
 
 
954
#ifdef WINCE
 
955
    {
 
956
        WCHAR tdir[TMPDIR_LEN];
 
957
        len = GetTempPath(TMPDIR_LEN, tdir);
 
958
        if ((len > 0) && (len < (TMPDIR_LEN - 6))) {
 
959
            /*
 
960
             * enough space for prdir
 
961
             */
 
962
            WideCharToMultiByte(CP_ACP, 0, tdir, -1, testdir, TMPDIR_LEN, 0, 0); 
 
963
        }
 
964
    }
 
965
#else
983
966
        len = GetTempPath(TMPDIR_LEN, testdir);
 
967
#endif      /* WINCE */
 
968
 
984
969
        if ((len > 0) && (len < (TMPDIR_LEN - 6))) {
985
970
                /*
986
971
                 * enough space for prdir
989
974
                TEST_DIR = testdir;
990
975
                printf("TEST_DIR = %s\n",TEST_DIR);
991
976
        }
992
 
        
993
 
#endif
 
977
#endif      /* WIN32 */
994
978
 
995
979
        if (FileTest() < 0) {
996
980
                printf("File Test failed\n");