Farbflash projects: Imaging lingo table | 3-D scene list | Find all | Handler menu | Lingo message window

Ignore:
Timestamp:
12/18/09 15:27:43 (2 years ago)
Author:
alex
Message:

enclosed path to svn application and editor application in quotes, because that fails otherwise, if the path has spaces. what a fun it is to be able to have spaces in file and foldernames... :-(

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/lingosource/castlib2/FileIOFunktionen.ls

    r186 r241  
    77-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    88 
    9 on mGetTextFromFile me, pfad 
     9on mGetTextFromFile me, pfad, readByteArray, useCharSet 
    1010  retval = "" 
    11    
    1211  if the runmode contains "Plugin" then return retval 
    1312   
    1413  fio = new(xtra "fileio") 
    15    
    1614  if not objectP(fio) then return retval 
     15   
     16  useCharSet = string(useCharSet) 
     17  if length(useCharSet) > 0 then 
     18    if xscr().mGetVersionNumber() > 11.4 then 
     19      ------------- don't need to check whether the given charset is supported 
     20      ------------- as it is simply ignored, if it isn't 
     21      ------------- and it also gets reset so that the next instance of fileio 
     22      ------------- uses the default utf-8 again 
     23      --      installedCharSets = _system.getInstalledCharSets() 
     24      --      if installedCharSets.getPos(useCharSet) > 0 then fio.setCharSet(useCharSet) 
     25      fio.setCharSet(useCharSet) 
     26    end if 
     27  end if 
    1728   
    1829  if (voidP(pfad) or (pfad = "")) then pfad = mGetFilePathFromUser(me) 
     
    2031  if ilk(pfad) = #string then 
    2132    if pfad.length > 0 then 
    22        
    2333      fio.openFile(pfad, 1) 
    2434      if fio.status() = 0 then 
    25          
    26         retval = fio.readFile() 
     35        if readByteArray = 1 then retval = fio.readByteArray(fio.getlength()) 
     36        else retval = fio.readFile() 
    2737        fio.closeFile() 
    2838      end if 
     
    3343end 
    3444 
     45-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     46 
     47on mGetByteArrayFromFile me, thePath 
     48  return mGetTextFromFile(me, thePath, (xscr().mGetVersionNumber() > 11.49)) 
     49end 
    3550 
    3651-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     
    4459-- paramList[#target] = instance 
    4560-- -- optional: 
    46 -- params[#theTimeOut] = 4000 -- milliseconds until operation times out 
    47 -- params[#progressHandler] = #progresscallbackFromGetText -- event sent whenever the percent done changes 
     61-- paramList[#theTimeOut] = 4000 -- milliseconds until operation times out 
     62-- paramList[#progressHandler] = #progresscallbackFromGetText -- event sent whenever the percent done changes 
     63-- paramList[#isByteArray] = 0 -- boolean value, only D11 
     64-- paramList[#charset] = "windows-1252" -- string, only D11 
    4865-- -- paramList[#customdata] = "whatever you need" 
     66-- xscr(#FileIOFunktionen).mGetTextFromFileAsync(paramList) 
     67 
    4968-- 
    5069--on callbackFromGetText me, paramList 
     
    6382  if not(internetLink) then internetLink = (fname starts "www.") 
    6483  if the runmode contains "plugin" or internetLink then 
    65     --    scr = xscr().mGetInstance("NetLingoManagerPS__") 
     84     
     85    --    scr = xscr().mGetInstance("NetLingoManagerPS") 
    6686    --    if ilk(scr) = #instance then 
    6787    --      scr.mStartNetOP(paramList) 
     
    7797    --    end if 
    7898  else 
    79     paramList.setaprop(#theTextResult, mGetTextFromFile(me, paramList.getaprop(#theURL))) 
     99    paramList.setaprop(#theTextResult, mGetTextFromFile(me, paramList.getaprop(#theURL), paramList[#isByteArray], paramList[#charset])) 
    80100    call(paramList.getaprop(#handler), [paramList.getaprop(#target)], paramList) 
    81101  end if 
     
    83103 
    84104-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
     105 
     106on mGetByteArrayFromFileAsync me, paramList 
     107  paramList[#isByteArray] = 1 
     108  mGetTextFromFileAsync me, paramList 
     109end 
     110 
     111-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    85112-- xxxxxxxxxxxxxxxxxx Write text out to a file 
    86113-- xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx 
    87114 
    88 on mSaveToTextFile me, theText, pfad, theTitle, theDefaultName, startfolder 
     115on mSaveToTextFile me, theText, pfad, theTitle, theDefaultName, startfolder, useCharSet 
    89116  retval = 0 
    90117   
     
    98125    fio = new(xtra "fileio") 
    99126    if not objectP(fio) then return retval 
     127     
     128    useCharSet = string(useCharSet) 
     129    if length(useCharSet) > 0 then 
     130      if xscr().mGetVersionNumber() > 11.4 then 
     131        ------------- don't need to check whether the given charset is supported 
     132        ------------- as it is simply ignored, if it isn't 
     133        ------------- and it also gets reset so that the next instance of fileio 
     134        ------------- uses the default utf-8 again 
     135        --      installedCharSets = _system.getInstalledCharSets() 
     136        --      if installedCharSets.getPos(useCharSet) > 0 then fio.setCharSet(useCharSet) 
     137        fio.setCharSet(useCharSet) 
     138      end if 
     139    end if 
     140     
    100141     
    101142    if ilk(theTitle) <> #string then theTitle = "Save File" 
Note: See TracChangeset for help on using the changeset viewer.