Get the filesize?

Chipp Walters chipp at chipp.com
Tue Feb 5 03:32:01 EST 2002


I'm on a PC...

This looks like the ticket, Shao. Thx! I thought there might be an easier
way. BTW, I think I'll insert a put the defaultFolder into oldDefaultFolder
before changing it, that way I can restore it at the end.

best,

Chipp

-----Original Message-----
From: use-revolution-admin at lists.runrev.com
[mailto:use-revolution-admin at lists.runrev.com]On Behalf Of Shao Sean
Sent: Tuesday, February 05, 2002 2:18 AM
To: use-revolution at lists.runrev.com
Subject: Re: Get the filesize?


returns -1 if it can't find the file.. you can change this to suit your
needs

-- Start code --
function getFileSize pFullFilePath
  # Declare the variables
  local vFilePath, vFileName, vDirectoryListing, vDirectoryListingLine

  # Split the file's path and name
  set the itemDelimiter to "/"
  put the last item of pFullFilePath into vFileName
  put pFullFilePath into vFilePath
  delete last item of vFilePath
  set the itemDelimiter to comma

  # Change the directory
  set the defaultFolder to vFilePath

  # Get the directory listing
  put the detailed files into vDirectoryListing

  # Find our file and return the file size
  if (vFileName is among the items of vDirectoryListing) then
    repeat for each line vDirectoryListingLine in vDirectoryListing
      if (item 1 of vDirectoryListingLine = vFileName) then
        if (the platform is "MacOS") then
          return item 2 of vDirectoryListingLine + item 3 of
vDirectoryListingLine
        else
          return item 2 of vDirectoryListingLine
        end if
      end if
    end repeat
  else
    return -1
  end if
end getFileSize
-- End Code --

_______________________________________________
use-revolution mailing list
use-revolution at lists.runrev.com
http://lists.runrev.com/mailman/listinfo/use-revolution




More information about the Use-livecode mailing list