source: sans/Dev/trunk/NCNR_User_Procedures/Common/Installer/NCNR_Install.ipf @ 659

Last change on this file since 659 was 659, checked in by srkline, 13 years ago

Moved the NCNR_Package_Loader to a new NCNR_Igor_Procedures folder in the install packge. Changed the installer to put this file in the Igor Procedures, to be always available. Updated the FilesToRemove?.itx waves to include the new folder ad possible contents.

File size: 23.7 KB
Line 
1#pragma rtGlobals=1             // Use modern global access method.
2#pragma IgorVersion=6.1
3
4
5
6///
7// ***********
8// it may be prefereable to COPY the files to the UP folder, so that the installer doesn't "eat" itself
9// and require users to re-download if they do something wrong. the difficulty with CopyFolder is that
10// on Windows it does a "mix-in" copy, rather than a delete/overwrite all. So it may be better to just leave
11// the installer as is, requiring a fresh copy each time. SRK 10MAR09
12//
13//
14///
15
16// Install the NCNR Macros
17
18//InstallNCNRMacros() // run this function when experiment is loaded
19//InstallerPanel() // run this function when experiment is loaded
20
21//
22// package-6.001
23// - lots more diagnostics added
24
25// FEB 2010 - now make use of the user-specific procedure path. It's always writeable, and not in the application folder
26//
27// since old material may be installed, and permission may be gone:
28// - check for permission
29// - check for old material installed in Igor Pro/
30// -- if nothing installed in Igor Pro/, then permissions are not a problem
31// -- install in the new uer-specific path as intended
32//
33// -- now I need to search both locations to move old stuff out
34// -- then install clean into the new user path (userPathStr)
35//
36// ** The NCNR_Package_Loader is now installed in the Igor Procedures folder so that the package can be loaded at any time
37//    improving compatibility with Jan Ilavsky's package
38//
39
40Function InstallNCNRMacros(forceInstall)
41        Variable forceInstall           // if == 1, install whatever possible, even if R/W errors from the OS
42
43        //first step, check for Igor 6!!!
44        if(NumberByKey("IGORVERS", IgorInfo(0)) < 6)
45                Abort "You must be running Igor 6 or later to use these macros."
46        endif
47       
48       
49        // check to see if the installer has already been run... if so, the folders will be gone... stop now BEFORE removing things
50        String test = IndexedDir(home, -1, 0)   
51        if(stringmatch(test, "*NCNR_User_Procedures*") == 0)
52                print test
53                Abort "You've already run the installer. If you want to re-install, you'll need a fresh copy from the NCNR website."
54        endif
55       
56        // check for install problems
57        // locked folders, OS errors _err will be non-zero if there is an error
58        Variable UP_err,IH_err,IE_err
59        UP_err = FolderPermissionCheck("User Procedures:")
60        IH_err = FolderPermissionCheck("Igor Help Files:")
61        IE_err = FolderPermissionCheck("Igor Extensions:")     
62//      Print UP_err,IH_err,IE_err
63
64        String alertStr=""
65        if(UP_err != 0)
66                alertStr += "User Procedures has no write permission.\r"
67        endif
68        if(IH_err != 0)
69                alertStr += "Igor Help Files has no write permission.\r"
70        endif
71        if(IE_err != 0)
72                alertStr += "Igor Extensions has no write permission.\r"
73        endif
74
75/// SRK - 2010 - errors are not used here. instead, errors are caught if a file or folder move fails. If there
76// is nothing to move out, or it moves out OK, then permissions don't matter.
77       
78//      if(forceInstall == 0)
79//              if(UP_err != 0 || IH_err != 0 || IE_err != 0)
80//                      alertStr += "You will need to install manually."
81//                      DoAlert 0,alertStr
82//                      return(0)
83//              endif
84//      endif
85       
86       
87        // check the platform
88        Variable isMac=0
89        if(cmpstr("Macintosh",IgorInfo(2))==0)
90                isMac=1
91        endif
92       
93
94        String igorPathStr,homePathStr,userPathStr
95        PathInfo Igor
96        igorPathStr = S_Path            //these have trailing colons
97        PathInfo home                                   //the location where this was run from...
98        homePathStr = S_Path
99        // the Igor 6.1 User Procedure Path, same sub-folders as in Igor App Folder
100        userPathStr=RemoveEnding(SpecialDirPath("Igor Pro User Files",0,0,0),":")+":"
101       
102        // clean up old stuff, moving to home:old_moved_files
103        // extensions - these show up as files, even the aliases
104        // help files - these are files
105        // user procedures - these can be in folders or as files
106        variable i=0, AliasSet=0, isThere = 0
107        String tmpStr
108
109
110//////////////////////////////////////////////////////////////////////
111       
112////// clean up the Igor Extensions (first the old path -- in the App folder)
113        NewPath /Q/O ExPath, igorPathStr+"Igor Extensions:"
114        PathInfo ExPath
115        String extPathStr = S_Path
116        string strFileList = IndexedFile(ExPath, -1, "????" )
117       
118        //files first
119        Wave/T extFiles=root:IExtFiles
120        for (i=0; i<itemsInList(strFileList); i+=1)
121                tmpStr = StringFromList(i,strFileList)
122                isThere = CheckForMatch(tmpStr,extFiles)
123                if(isThere)
124                        MoveFile/O/P=ExPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
125                        Print "Move file "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
126                endif
127        endfor
128       
129        //then anything that shows up as a folder
130        Wave/T extFolders=root:IExtFolders
131        strFileList = IndexedDir(ExPath, -1, 0 )
132       
133        for (i=0; i<itemsInList(strFileList); i+=1)
134                tmpStr = StringFromList(i,strFileList)
135                isThere = CheckForMatch(tmpStr,extFolders)
136                if(isThere)
137                        MoveFolder extPathStr+tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
138                        Print "Move folder "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
139                endif
140        endfor
141
142////// then clean up the Igor Extensions (now look in the User Path, by changing the definition of ExPath)
143        NewPath /Q/O ExPath, userPathStr+"Igor Extensions:"
144        PathInfo ExPath
145        extPathStr = S_Path
146        strFileList = IndexedFile(ExPath, -1, "????" )
147               
148        for (i=0; i<itemsInList(strFileList); i+=1)
149                tmpStr = StringFromList(i,strFileList)
150                isThere = CheckForMatch(tmpStr,extFiles)
151                if(isThere)
152                        MoveFile/O/P=ExPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
153                        Print "Move file "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
154                endif
155        endfor
156       
157        //then anything that shows up as a folder
158        strFileList = IndexedDir(ExPath, -1, 0 )
159        for (i=0; i<itemsInList(strFileList); i+=1)
160                tmpStr = StringFromList(i,strFileList)
161                isThere = CheckForMatch(tmpStr,extFolders)
162                if(isThere)
163                        MoveFolder extPathStr+tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
164                        Print "Move folder "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
165                endif
166        endfor
167
168//////////////////////////////////////////////////////////////////////
169       
170/////// clean up the User Procedures -- in the APP folder
171        NewPath /Q/O UPPath, igorPathStr+"User Procedures:"
172        PathInfo UPPath
173        String UPPathStr = S_Path
174        strFileList = IndexedFile(UPPath, -1, "????" )                  //for files
175       
176        // (files first)
177        Wave/T UPFilesWave=root:UPFiles
178        for (i=0; i<itemsInList(strFileList); i+=1)
179                tmpStr = StringFromList(i,strFileList)
180                isThere = CheckForMatch(tmpStr,UPFilesWave)
181                if(isThere)
182                        MoveFile/O/P=UPPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
183                        Print "Move file "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
184                endif
185        endfor
186       
187        //(folders second)
188        strFileList = IndexedDir(UPPath, -1, 0)                 //for folders, just the names, not full paths
189        Wave/T UPFoldersWave=root:UPFolders
190       
191        for (i=0; i<itemsInList(strFileList); i+=1)
192                tmpStr = StringFromList(i,strFileList)
193                isThere = CheckForMatch(tmpStr,UPFoldersWave)
194                if(isThere)
195                // THIS is the problem, when NCNR_Help_Files is moved - it is in use
196                        MoveFolder/Z UPPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
197                        Print "Move folder "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
198                endif
199        endfor
200
201/////// now clean up the User Procedures -- in the User Folder
202        NewPath /Q/O UPPath, userPathStr+"User Procedures:"
203        PathInfo UPPath
204        UPPathStr = S_Path
205        strFileList = IndexedFile(UPPath, -1, "????" )                  //for files
206       
207        // (files first)
208        for (i=0; i<itemsInList(strFileList); i+=1)
209                tmpStr = StringFromList(i,strFileList)
210                isThere = CheckForMatch(tmpStr,UPFilesWave)
211                if(isThere)
212                        MoveFile/O/P=UPPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
213                        Print "Move file "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
214                endif
215        endfor
216       
217        //(folders second)
218        strFileList = IndexedDir(UPPath, -1, 0)                 //for folders, just the names, not full paths
219               
220        for (i=0; i<itemsInList(strFileList); i+=1)
221                tmpStr = StringFromList(i,strFileList)
222                isThere = CheckForMatch(tmpStr,UPFoldersWave)
223                if(isThere)
224                // THIS is the problem, when NCNR_Help_Files is moved - it is in use
225                        MoveFolder/Z UPPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
226                        Print "Move folder "+ tmpStr + " from User Procedures: "+IsMoveOK(V_flag)
227                endif
228        endfor
229
230
231//////////////////////////////////////////////////////////////////////
232
233
234
235/////// now try to clean up the Igor Help Files (in the APP folder)
236        NewPath /Q/O IHPath, igorPathStr+"Igor Help Files:"
237        PathInfo IHPath
238        String IHPathStr = S_Path
239        strFileList = IndexedFile(IHPath, -1, "????" )                  //for files
240       
241        // files first
242        Wave/T IHFilesWave=root:IHFiles
243       
244        for (i=0; i<itemsInList(strFileList); i+=1)
245                tmpStr = StringFromList(i,strFileList)
246                isThere = CheckForMatch(tmpStr,IHFilesWave)
247                if(isThere)
248                        MoveFile/O/P=IHPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
249                        Print "Move file "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
250                endif
251        endfor 
252       
253        // then anything that shows up as a folder
254        Wave/T IHFilesWave=root:IHFolders
255        strFileList = IndexedDir(IHPath, -1, 0)
256       
257        for (i=0; i<itemsInList(strFileList); i+=1)
258                tmpStr = StringFromList(i,strFileList)
259                isThere = CheckForMatch(tmpStr,IHFolders)
260                if(isThere)
261                        MoveFolder IHPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
262                        Print "Move folder "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
263                endif
264        endfor
265       
266        /////// now try the Igor Help Files (in the USER folder)
267        NewPath /Q/O IHPath, userPathStr+"Igor Help Files:"
268        PathInfo IHPath
269        IHPathStr = S_Path
270        strFileList = IndexedFile(IHPath, -1, "????" )                  //for files
271       
272        // files first 
273        for (i=0; i<itemsInList(strFileList); i+=1)
274                tmpStr = StringFromList(i,strFileList)
275                isThere = CheckForMatch(tmpStr,IHFilesWave)
276                if(isThere)
277                        MoveFile/O/P=IHPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
278                        Print "Move file "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
279                endif
280        endfor 
281       
282        // then anything that shows up as a folder
283        strFileList = IndexedDir(IHPath, -1, 0)
284       
285        for (i=0; i<itemsInList(strFileList); i+=1)
286                tmpStr = StringFromList(i,strFileList)
287                isThere = CheckForMatch(tmpStr,IHFolders)
288                if(isThere)
289                        MoveFolder IHPathStr + tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
290                        Print "Move folder "+ tmpStr + " from Igor Help Files: "+IsMoveOK(V_flag)
291                endif
292        endfor
293
294///////////////////
295////// clean up the Igor Procedures (first the old path -- in the App folder, likely empty)
296        NewPath /Q/O IgProcPath, igorPathStr+"Igor Procedures:"
297        PathInfo IgProcPath
298        String IgProcPathStr = S_Path
299        strFileList = IndexedFile(IgProcPath, -1, "????" )
300       
301        //files first
302        Wave/T IgProcFiles=root:IgProcFiles
303        for (i=0; i<itemsInList(strFileList); i+=1)
304                tmpStr = StringFromList(i,strFileList)
305                isThere = CheckForMatch(tmpStr,IgProcFiles)
306                if(isThere)
307                        MoveFile/O/P=IgProcPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
308                        Print "Move file "+ tmpStr + " from Igor Procedures: "+IsMoveOK(V_flag)
309                endif
310        endfor
311       
312        //then anything that shows up as a folder (don't bother with this)
313        Wave/T IgProcFolders=root:IgProcFolders
314       
315        strFileList = IndexedDir(IgProcPath, -1, 0 )
316        for (i=0; i<itemsInList(strFileList); i+=1)
317                tmpStr = StringFromList(i,strFileList)
318                isThere = CheckForMatch(tmpStr,IgProcFolders)
319                if(isThere)
320                        MoveFolder IgProcPathStr+tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
321                        Print "Move folder "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
322                endif
323        endfor
324
325////// then clean up the Igor Procedures (now look in the User Path, by changing the definition of IgProcPath)
326        NewPath /Q/O IgProcPath, userPathStr+"Igor Procedures:"
327        PathInfo IgProcPath
328        IgProcPathStr = S_Path
329        strFileList = IndexedFile(IgProcPath, -1, "????" )
330               
331        for (i=0; i<itemsInList(strFileList); i+=1)
332                tmpStr = StringFromList(i,strFileList)
333                isThere = CheckForMatch(tmpStr,IgProcFiles)
334                if(isThere)
335                        MoveFile/O/P=IgProcPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
336                        Print "Move file "+ tmpStr + " from Igor Procedures: "+IsMoveOK(V_flag)
337                endif
338        endfor
339
340        //then anything that shows up as a folder
341        strFileList = IndexedDir(IgProcPath, -1, 0 )
342        for (i=0; i<itemsInList(strFileList); i+=1)
343                tmpStr = StringFromList(i,strFileList)
344                isThere = CheckForMatch(tmpStr,IgProcFolders)
345                if(isThere)
346                        MoveFolder IgProcPathStr+tmpStr as homePathStr+"NCNR_Moved_Files:NCNR_Moved_Folders:"+tmpStr
347                        Print "Move folder "+ tmpStr + " from Igor Extensions: "+IsMoveOK(V_flag)
348                endif
349        endfor
350
351//////////////////////////////////////////////////////////////////////
352       
353
354// at this point all of the old stuff is cleaned up as best as I can
355//
356// at this point the paths point to the User Folder, not in the App folder     
357       
358       
359       
360       
361//////////// INSTALL the new stuff
362//
363//(1) copy the items to install to the User Special Folder
364//(2) --- now I don't need to set up aliases! they are just there
365//
366// the old ones should be gone already, so just put in the new ones
367
368// they may not be possible to remove, so try to overwrite...
369
370        NewPath /Q/O SpecialPath, userPathStr
371
372// the help files
373        MoveFolder/Z=1 homePathStr+"NCNR_Help_Files" as IHPathStr+"NCNR_Help_Files"
374        Print "******Move folder NCNR_Help_Files into User Special Folder, NO overwite: "+IsMoveOK(V_flag)
375
376// not needed now
377//      CreateAliasShortcut/O/P=SpecialPath "NCNR_Help_Files" as igorPathStr+"Igor Help Files:NCNR_Help_Files"
378//      Print "Creating shortcut from NCNR_Help_Files into Igor Help Files: "+IsMoveOK(V_flag)
379
380// the Igor Procedures
381        MoveFolder/Z=1 homePathStr+"NCNR_Igor_Procedures" as IgProcPathStr+"NCNR_Igor_Procedures"
382        Print "*******Move folder NCNR_Igor_Procedures into User Special Folder, NO overwrite: "+IsMoveOK(V_flag)
383
384// the User Procedures 
385        MoveFolder/Z=1 homePathStr+"NCNR_User_Procedures" as UPPathStr+"NCNR_User_Procedures"
386        Print "*******Move folder NCNR_User_Procedures into User Special Folder, NO overwrite: "+IsMoveOK(V_flag)
387       
388// don't need an alias for the UserProcedures - they're already here....
389
390
391// Igor Extensions, platform-specific
392        if(isMac)
393                MoveFolder/Z=1 homePathStr+"NCNR_Extensions:Mac_XOP" as extPathStr+"NCNR_Extensions"
394        else
395                MoveFolder/Z=1 homePathStr+"NCNR_Extensions:Win_XOP" as extPathStr+"NCNR_Extensions"
396        endif
397        Print "*******Move folder NCNR_Extensions:xxx_XOP into User Special Folder, NO overwrite: "+IsMoveOK(V_flag)
398//     
399// not needed now
400//      if(isMac)
401//              CreateAliasShortcut/O/P=UPPath "NCNR_Extensions:Mac_XOP" as igorPathStr+"Igor Extensions:NCNR_Extensions"
402//      else
403//              CreateAliasShortcut/O/P=UPPath "NCNR_Extensions:Win_XOP" as igorPathStr+"Igor Extensions:NCNR_Extensions"
404//      endif
405//      Print "Creating shortcut for XOP into Igor Extensions: "+IsMoveOK(V_flag)
406       
407
408// put shortcuts to the template in the "top" folder
409//
410        NewPath/O/Q UtilPath, homePathStr+"NCNR_SANS_Utilities:"
411        strFileList = IndexedFile(UtilPath,-1,".pxt")   
412        for (i=0; i<itemsInList(strFileList); i+=1)
413                tmpStr = StringFromList(i,strFileList)
414//              isThere = CheckForMatch(tmpStr,IHFolders)
415//              if(isThere)
416//                      Print "Move "+ tmpStr
417//                      MoveFolder/O/P=IHPath tmpStr as homePathStr+"NCNR_Moved_Files:"+tmpStr
418                        CreateAliasShortcut/O/P=UtilPath tmpStr as homePathStr +tmpStr
419                        Print "Creating shortcut for "+tmpStr+" into top level: "+IsMoveOK(V_flag)
420//              endif
421        endfor
422
423
424// installation is done, quit to start fresh
425        DoAlert 1, "Quit Igor to complete installation.\rQuit now? "
426        if (V_Flag==1)
427                execute "Quit /Y"
428        endif
429       
430        return 1
431End
432
433// return (1) if str is an entry in tw
434// must be an exact match, with or without ".lnk" extension
435//
436Function CheckForMatch(str,tw)
437        String str
438        Wave/T tw
439       
440        Variable num=numpnts(tw),ii=0
441       
442        do
443                if(cmpstr(str,tw[ii])==0 || cmpstr(str,tw[ii]+".lnk")==0)
444                        return (1)
445                endif
446                ii+=1
447        while(ii<num)
448       
449        return(0)
450End
451
452
453Function InstallButtonProc(ba) : ButtonControl
454        STRUCT WMButtonAction &ba
455
456        switch( ba.eventCode )
457                case 2: // mouse up
458                        // click code here
459                        InstallNCNRMacros(0)
460                        break
461        endswitch
462
463        return 0
464End
465
466Function UpdateCheckButtonProc(ba) : ButtonControl
467        STRUCT WMButtonAction &ba
468
469        switch( ba.eventCode )
470                case 2: // mouse up
471                        // click code here
472                        Execute "CheckForLatestVersion()"
473                        break
474        endswitch
475
476        return 0
477End
478
479Function DiagnosticsProc(ba) : ButtonControl
480        STRUCT WMButtonAction &ba
481
482        switch( ba.eventCode )
483                case 2: // mouse up
484                        // click code here
485                        InstallDiagnostics()
486                        break
487        endswitch
488
489        return 0
490End
491
492Window InstallerPanel() : Panel
493        PauseUpdate; Silent 1           // building window...
494        NewPanel /W=(150,50,445,292)    /K=2
495        Button button0,pos={73,24},size={150,40},proc=InstallButtonProc,title="Install SANS Macros"
496        Button button0,fColor=(1,26214,0)
497        Button button0_1,pos={75,94},size={150,40},proc=UpdateCheckButtonProc,title="Check for Updates"
498        Button button0_1,fColor=(1,26221,39321)
499        Button button0_2,pos={75,164},size={150,40},proc=DiagnosticsProc,title="Print Diagnostics"
500        Button button0_2,fColor=(65535,0,0)
501EndMacro
502
503// generate a notebook with install diagnostics suitable for e-mail
504Function InstallDiagnostics()
505       
506        String nb="Install_Diagnostics_v6",textStr
507       
508        DoWindow/F $nb
509        if(V_flag==0)
510                NewNotebook/N=$nb/F=0 /W=(387,44,995,686) as nb
511        else
512                //clear contents
513                Notebook $nb selection={startOfFile, endOfFile}
514                Notebook $nb text="\r"
515        endif   
516       
517// what version, what platform
518        Notebook $nb text="**Install Diagnostics**\r\r"
519        Notebook $nb text="**Version / Platform**\r"
520        textStr =  IgorInfo(0)+"\r"
521        Notebook $nb text=textStr
522        textStr =  IgorInfo(2)+"\r"
523        Notebook $nb text=textStr
524// what is the currently installed version from the string
525        PathInfo Igor
526        String IgorPathStr = S_Path
527        String fileNameStr = IgorPathStr + "User Procedures:NCNR_User_Procedures:InstalledVersion.txt"
528        String installedStr
529        Variable refnum
530       
531        Open/R/Z refNum as fileNameStr
532        if(V_flag != 0)
533                //couldn't find the file
534                textstr = "I could not determine what version of the SANS Macros you are running."
535        else
536                FReadLine refNum, installedStr
537                Close refnum
538                textStr = installedStr
539        endif
540       
541        // check for permissions
542        Variable UP_err,IH_err,IE_err
543        UP_err = FolderPermissionCheck("User Procedures:")
544        IH_err = FolderPermissionCheck("Igor Help Files:")
545        IE_err = FolderPermissionCheck("Igor Extensions:")
546       
547        Print UP_err,IH_err,IE_err
548       
549        String alertStr=""
550        if(UP_err != 0)
551                alertStr += "User Procedures has no write permission. Error = "+num2Str(UP_err)+"\r"
552        else
553                alertStr += "User Procedures permission is OK.\r"
554        endif
555        if(IH_err != 0)
556                alertStr += "Igor Help Files has no write permission. Error = "+num2Str(IH_err)+"\r"
557        else
558                alertStr += "Igor Help Files permission is OK.\r"
559        endif
560        if(IE_err != 0)
561                alertStr += "Igor Extensions has no write permission. Error = "+num2Str(IE_err)+"\r"
562        else
563                alertStr += "Igor Extensions permission is OK.\r"
564        endif
565       
566        if(UP_err != 0 || IH_err != 0 || IE_err != 0)
567                alertStr += "You will need to install manually."
568        endif
569       
570        Notebook $nb text="\r\r**Folder Permissions**\r"
571        Notebook $nb text=AlertStr +"\r"
572       
573       
574        Notebook $nb text="\r\r**InstalledVersion.txt**\r"
575        Notebook $nb text=textStr +"\r"
576
577// get listings of everything in each folder
578        string strfileList=""
579
580// what is the listing of the Igor Extensions
581        Notebook $nb text="\r\r**Igor Extensions (files)**\r"
582        NewPath /Q/O ExPath, igorPathStr+"Igor Extensions:"
583       
584        //files
585        strFileList = IndexedFile(ExPath, -1, "????" )
586        textStr = ReplaceString(";", strFileList, "\r")
587        Notebook $nb text=textStr
588
589        //folders
590        Notebook $nb text="\r**Igor Extensions (folders)**\r"
591        strFileList = IndexedDir(ExPath, -1, 0 )
592        textStr = ReplaceString(";", strFileList, "\r")
593        Notebook $nb text=textStr+"\r"
594
595
596// what is the listing of Igor Help files
597        Notebook $nb text="\r\r**Igor Help (files)**\r"
598        NewPath /Q/O IHPath, igorPathStr+"Igor Help Files:"
599
600        //files
601        strFileList = IndexedFile(IHPath, -1, "????" )
602        textStr = ReplaceString(";", strFileList, "\r")
603        Notebook $nb text=textStr
604
605        //folders
606        Notebook $nb text="\r**Igor Help (folders)**\r"
607        strFileList = IndexedDir(IHPath, -1, 0 )
608        textStr = ReplaceString(";", strFileList, "\r")
609        Notebook $nb text=textStr+"\r"
610       
611       
612// what is the listing of the User Procedures
613        Notebook $nb text="\r\r**User Procedures (files)**\r"
614        NewPath /Q/O UPPath, igorPathStr+"User Procedures:"
615        //files
616        strFileList = IndexedFile(UPPath, -1, "????" )
617        textStr = ReplaceString(";", strFileList, "\r")
618        Notebook $nb text=textStr
619
620        //folders
621        Notebook $nb text="\r**User Procedures (folders)**\r"
622        strFileList = IndexedDir(UPPath, -1, 0 )
623        textStr = ReplaceString(";", strFileList, "\r")
624        Notebook $nb text=textStr+"\r"
625       
626// what is the listing of the Igor Procedures
627
628//  generating a path for this seems to be problematic - since it can't be killed , or found on another computer
629// that is (apparently) because if there is anything included from the IgP folder (and there is on even the default installation)
630// - then the path is "in use" and can't be killed...
631//
632        Notebook $nb text="\r\r**Igor Procedures (files)**\r"
633        NewPath /Q/O IgorProcPath, igorPathStr+"Igor Procedures:"
634
635        //files
636        strFileList = IndexedFile(IgorProcPath, -1, "????" )
637        textStr = ReplaceString(";", strFileList, "\r")
638        Notebook $nb text=textStr
639
640        //folders
641        Notebook $nb text="\r**Igor Procedures (folders)**\r"
642        strFileList = IndexedDir(IgorProcPath, -1, 0 )
643        textStr = ReplaceString(";", strFileList, "\r")
644        Notebook $nb text=textStr+"\r"
645//
646//
647        // then get a listing of the "home" directory. If files were not moved properly, they will still be here
648        Notebook $nb text="\r\r**Home (files)**\r"
649//      NewPath /Q/O IgorProcPath, igorPathStr+"Igor Procedures:"
650
651        //files
652        strFileList = IndexedFile(home, -1, "????" )
653        textStr = ReplaceString(";", strFileList, "\r")
654        Notebook $nb text=textStr
655
656        //folders
657        Notebook $nb text="\r**Home (folders)**\r"
658        strFileList = IndexedDir(home, -1, 0 )
659        textStr = ReplaceString(";", strFileList, "\r")
660        Notebook $nb text=textStr+"\r"
661       
662        //move to the beginning of the notebook
663        Notebook $nb selection={startOfFile, startOfFile}       
664        Notebook $nb text=""
665       
666        return(0)
667End
668
669Function AskUserToKillHelp()
670
671        //// clean up the Igor help files
672// first, kill any open help files
673// there are 5 of them
674        Variable numHelpFilesOpen=0
675//      do
676                numHelpFilesOpen = 0
677                // V_flag is set to zero if it's found, non-zero (unspecified value?) if it's not found
678                DisplayHelpTopic/Z "Beta SANS Tools"
679                if(V_flag==0)
680                        numHelpFilesOpen += 1
681                endif
682               
683                DisplayHelpTopic/Z "SANS Data Analysis Documentation"
684                if(V_flag==0)
685                        numHelpFilesOpen += 1
686                endif
687                               
688                DisplayHelpTopic/Z "SANS Model Function Documentation"
689                if(V_flag==0)
690                        numHelpFilesOpen += 1
691                endif
692                               
693                DisplayHelpTopic/Z "SANS Data Reduction Tutorial"
694                if(V_flag==0)
695                        numHelpFilesOpen += 1
696                endif
697                               
698                DisplayHelpTopic/Z "USANS Data Reduction"
699                if(V_flag==0)
700                        numHelpFilesOpen += 1
701                endif
702                       
703//              PauseForUser            // can't use this, it keeps you from interacting with anything....
704//      while(NumHelpFilesOpen != 0)
705        DoWindow HelpNotebook
706        if(V_flag)
707                DoWindow/K HelpNotebook
708        endif
709       
710        String helpStr = "Please kill the open Help Files by holding down the OPTION key (Macintosh) or ALT key (Windows) and then CLICKING on the close box of each help window."
711        helpStr += " Once you have finished, please close this window and install the SANS Macros."
712        if(NumHelpFilesOpen != 0)
713                NewNotebook/F=1/K=1/N=HelpNotebook /W=(5,44,547,380) as "Please close the open help files"
714                Notebook HelpNotebook,fsize=18,fstyle=1,showRuler=0,text=helpStr
715                return(0)
716        endif
717
718        return(0)
719End
720
721//check each of the three folders
722// folder string MUST have the trailing colon
723Function FolderPermissionCheck(folderStr)
724        String folderStr
725        Variable refnum
726        String str="delete me"
727       
728        String igorPathStr,resultStr=""
729        PathInfo Igor
730        igorPathStr = S_Path
731       
732        NewPath /Q/O tmpPath, igorPathStr+folderStr
733
734       
735        Open/Z/P=tmpPath refnum as "test.txt"
736        if(V_flag != 0)
737                return(V_flag)
738        else
739                FBinWrite refnum,str
740                Close refnum
741               
742//              Print "folder OK"
743                DeleteFile/Z/P=tmpPath  "test.txt"
744        endif
745       
746       
747        return(V_flag)
748end
749
750Function/S IsMoveOK(flag)
751        Variable flag
752       
753        String alertStr="There are old NCNR procedures and files present. You will need admin privileges to manually remove them before you can continue"
754        if(flag == 0)
755                return(" OK")
756        else
757                DoAlert 0,alertStr
758                return(" ERROR")
759        endif
760end
761
762//// this will "force" an install, even if there are R/W errors
763//Macro ForceInstall()
764//
765//      Execute "InstallNCNRMacros(1)"
766//end
Note: See TracBrowser for help on using the repository browser.