How to? Handle unexpectedly inaccessible CWD

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
#1
As I am sure many others do, my CWD is often on a network drive, and my TCC prompt displays CWD. However, the network is subject to failure, and when that happens, I want to:
1/ terminate any command in progress that requires use of the network
2/ if the CWD is no longer accessible change to an accessible default.

I suspect ON ERROR is the primary method for 1/ above, and can deal with 2/ if the network failure occurs while a command is executed. However, how can I handle a network failure which occurs when TCC is waiting for a new command at the command prompt?
 

rconn

Administrator
Staff member
May 14, 2008
10,101
85
#3
The simple answer is no -- when TCC is at a prompt you can't interrupt it with another command.

The more complicated answer is yes, if you want to write a plugin that monitors network connections and then sends a ^C / ^Break signal to TCC if a connection is lost. (And couple that with a PROMPT command that checks for this and switches the drive.)
 
#4
The simple answer is no -- when TCC is at a prompt you can't interrupt it with another command.

The more complicated answer is yes, if you want to write a plugin that monitors network connections and then sends a ^C / ^Break signal to TCC if a connection is lost. (And couple that with a PROMPT command that checks for this and switches the drive.)
I looked into this a bit. Subscribing to NetworkLocationAwareness (NLS service) is quite far from trivial and (IMHO) seems simply not worth the trouble. And even that, I believe, involves polling. In a plugin, a very simply thread could very efficiently poll for the availability of _CWD but (again IMHO) even that seems like overkill.

Somewhere, I have code for an "EVERY" plugin command (EVERY N s|m|h command). You could probably use a simple (meant for the background) BTM to do some kind of monitoring. I abandoned that because I couldn't think of anything to do with it.
 
#5
A question for Rex: It _CWD is a network path and I disconnect from the network, this test fails to detect it.
Code:
if ( !GetCurrentDirectory(MAX_PATH,szCwd) || !SetCurrentDirectory(szCwd) )
That is, both functions continue to succeed. What fails in the expansion of _CWD causing this message from TCC?
Code:
\\lucky\v$> echo %_cwd
TCC: (Sys) The specified network name is no longer available.
 

rconn

Administrator
Staff member
May 14, 2008
10,101
85
#6
A question for Rex: It _CWD is a network path and I disconnect from the network, this test fails to detect it.
Code:
if ( !GetCurrentDirectory(MAX_PATH,szCwd) || !SetCurrentDirectory(szCwd) )
That is, both functions continue to succeed. What fails in the expansion of _CWD causing this message from TCC?
Code:
\\lucky\v$> echo %_cwd
TCC: (Sys) The specified network name is no longer available.

%_CWD first checks to see if the drive exists.