Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: (tye)Re: chdir does not work on win2000

by juo (Curate)
on May 31, 2001 at 17:15 UTC ( #84542=note: print w/ replies, xml ) Need Help??


in reply to (tye)Re: chdir does not work on win2000
in thread chdir does not work on win2000

Dear Tye, Are you using Win2000. With me it doesn't change the directory on Windows2000. When the browser open it shows me the directory last browsed too and not the directory that is returned by cwd(). The directory that is returned by cwd() is the directory were I started the script from. When I use chdir that directory has been changed but the directory in the browser stays untouched. When I browse to another location in the browser and I exit the browser that location is now stored and shown everytime I open the browser even when I reboot. It's that pointer I am not able to change. I believe it must be somewhere a setting in the windows2000 register that is not correct. On Windows NT it is working fine. Did anybody had simular problems ?

my $_pwd = getcwd(); print "$_pwd\n"; # shows c:/perl/training : directory were I start + from. chdir("c:\\public") or print STDERR "\n\tERROR in chdir: $!\n"; $_pwd = getcwd(); print "$_pwd\n"; # shows c:/perl/public: directory have been chang +ed


Comment on Re: (tye)Re: chdir does not work on win2000
Download Code
(tye)Re2: chdir does not work on win2000
by tye (Cardinal) on May 31, 2001 at 19:11 UTC

    Yes, my experiments were done on Win2K.

    Here is the documentation of the "problem" (from the documentation for the OPENFILENAME structure that is passed to the GetOpenFileName function):

    lpstrInitialDir (a field in that structure)

    Pointer to a string that specifies the initial file directory.

    Windows NT 5.0 and later; Windows 98 and later:

    If lpstrInitalDir is NULL and the current directory contains any files of the specified filter types, the initial directory is the current directory.

    If lpstrInitalDir is NULL and the current directory does not contain any files of the specified filter types, the initial directory is the personal files directory of the current user. To specify the current user's personal files directory as the initial directory, set lpstrInitialDir to the path returned by calling theSHGetSpecialFolderLocation function with the CSIDL_PERSONAL flag.

    Earlier versions of Windows and Windows NT:

    If lpstrInitalDir is NULL, the initial directory is the current directory.

    So I was close. The problem isn't with directories named "tmp", it is with directories that don't contain any files of the type you requested to be opened.

    The documentation implies that if you change this value to not be NULL, then things will work as you desire. Checking the source code for Tk (download Tk800_023_tar.gz from CPAN, extract files, find call to GetOpenFileName in Tk800.023\pTk\mTk\win\tkWinDialog.c, etc.) I see that specifying the -initialdir option should take care of that. Of course, you said that you already tried that. ):

    Perhaps you should experiment some more on exactly how you pass the -initialdir in. I know, for example, that file dialogues are one of the few places in Win32 that you can't type forward slash (/) as a directory separator. Perhaps the -initialdir also requires that only back slashes (\) be used?

            - tye (but my friends call me "Tye")

      Tye, You are a cool dude. You were right with you last statement. The -initialdir can only parse through (\) and not (/) The code below did the job right. Thaaaaaaaaaaaaaaaanks

      $file = $w->getOpenFile(-filetypes => \@types, - initialdir => "c:\\public",);

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://84542]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2014-08-30 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (291 votes), past polls