Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Bug reports
➜ problem opening relative path files while the "Add Plugin" dialog is open
|
problem opening relative path files while the "Add Plugin" dialog is open
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Fiendish
USA (2,551 posts) Bio
Global Moderator |
| Date
| Sun 12 Dec 2010 04:52 AM (UTC) |
| Message
| Here's an interesting scenario...
I just recently added the ability to log chats to a file in my channel capture plugin, and I noticed something weird that happened today. If a chat comes through, and the plugin subsequently tries to log the chat to a file, while I have the Add Plugin dialog open, the file open operation fails if you use GetInfo(58) (the logs directory path) if it is defined as a relative path.
Here's the error:
Run-time error
Plugin: Aardwolf_Chat_Capture_Miniwindow (called from world: Aardwolf)
Function/Sub: OnPluginBroadcast called by Plugin Aardwolf_Chat_Capture_Miniwindow
Reason: Executing plugin Aardwolf_Chat_Capture_Miniwindow sub OnPluginBroadcast
[string "Plugin"]:490: .\logs\AardwolfChatLog.txt: No such file or directory
stack traceback:
[C]: in function 'assert'
[string "Plugin"]:490: in function 'stampAndStore'
[string "Plugin"]:556: in function <[string "Plugin"]:546>
Error context in script:
486 : if (log_to_file == 1) then
487 : if (log_colour_codes == 0) then
488 : log_text = strip_colours(log_text)
489 : end
490*: local f = assert(io.open (GetInfo(58)..GetInfo(2).."ChatLog.txt", "a+")) -- handle to chat log file
491 : f:write (log_text.."\n") -- write to it
492 : f:close () -- close that file now
493 : end
494 :
I seem to have fixed it by replacing GetInfo(58) with
GetInfo(58):gsub("^\.\",GetInfo(56)) to construct an absolute path. |
https://github.com/fiendish/aardwolfclientpackage | | Top |
|
| Posted by
| Nick Gammon
Australia (23,169 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Sun 12 Dec 2010 05:11 AM (UTC) |
| Message
| I hate relative paths with a bit of a passion, as far as MUSHclient goes, because the question is "relative to what"?
It's one thing to be in a shell (eg. in Linux or DOS) and then say "cd foo" because you know it is "foo" relative to where you currently are, which hopefully you know.
But in MUSHclient, the current directory can be a bit fluid. Is it the starting directory? The executable directory? It can change if you script in a ChangeDir function call (as it is designed to do). And it can change if you use the file picker, and change directories.
So, you are basically better off using absolute paths. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
7,373 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top