Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to? Handle unexpectedly inaccessible CWD

May
3,515
5
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?
 
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.)
 
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.
 
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.
 
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.
 
%_CWD first checks to see if the drive exists.
How? The _CWD in question is "\\lucky\v$". I also tried IsPathDirectory() but that continues to succeed after a VPN has been connected.
 
Back
Top