ID:139674
 
Code:
client
Topic(ref, list[])
..()
switch(list["action"])
if("download_file")
var/f = list["file"]
src<<ftp(Default_Dir+"/"+f, "[f]")
return
if("display_file")
var/f = list["file"]
var/S = Default_Dir+"\\"+f
alert(src, "This : [S]")
mob.ViewFile(S)

proc
CreateViewTopic(File, Name)
if(!Name) Name = "View [File]"
return "<a href='?action=display_file;file=[File]'>[Name]</a>"

mob
proc
ViewFile(f)
f = file(f)
if(!isfile(f)) {src<<browse("Could Not Display Preview Of File");ViewBrowser();return}
if(isicon(f))//if this failed
var/F = fcopy_rsc(f)
winset(src, "display.display", "image=\ref[F]")
ShowIDisplay()
if(!isicon(f))//this will obviously work, its the same as else XD
var/F = file2text(f)//<--
src<<output(null, "display2.text")
src<<output(html_encode(F), "display2.text")
ShowTDisplay()
else
src<<browse("Failed To Read...")


Problem description:
Well, trying to make it so you can get a preview of your files but for some reason or another after clicking the view topic it isn't showing the preview...I'm pretty sure because its not getting the file as an argument, maybe it just doesn't see it as an icon, it works for text but that's about it.

In response to Masschaos100
Is the path provided when previewing (Default_Dir+"\\"+f) correct?

Are you able to download, just not preview these files?
Is the text files that you preview correct in their text?


- also
if(!isicon(f))//this will obviously work, its the same as else XD

This is an incorrect statement. If the supplied argument is an icon, it will display the else statement after this 100% of the time. This should be an else if.
In response to Pirion
(Default_Dir+"\\"+f) is correct

Text files are correct in the way they are previewed, it just doesn't see image files(.dmi files included) as actual images it just turns them into text.

-if(!isicon(f))//this will obviously work, its the same as else XD

Yeah I know, I was just hoping for a miracle.
In response to Masschaos100
Well, I figured that might be an issue...The isicon function seems to only return true when it's in the cache, not in file form...
In response to Pirion
Hmmm, Is that so? Any suggestions on a work around, or should I put it in Cache using fcopy_rsc()?
In response to Masschaos100
Yep, was just testing. fcopy_rsc does work. I couldn't get the /icon operator to work though. It should if used correctly, I just don't remember how.

Edit: I did get /icon to work by using { var/icon/A = new(file("xxx")) } but it incorrecty returns true on non-icon files, so won't work for what you need.
In response to Pirion
Thanks I fixed it :)