diff options
| author | Jason Rumney | 2008-01-26 01:08:53 +0000 |
|---|---|---|
| committer | Jason Rumney | 2008-01-26 01:08:53 +0000 |
| commit | 302d7d5465573c17de07f3addbdc6a63180c0b57 (patch) | |
| tree | ca68f1aea002da22e9c7c8e7826b5720dec81f7c /src | |
| parent | a5bafa401fc141892429a27ae18d46e8dde84446 (diff) | |
| download | emacs-302d7d5465573c17de07f3addbdc6a63180c0b57.tar.gz emacs-302d7d5465573c17de07f3addbdc6a63180c0b57.zip | |
(logon_network_drive): New function.
(stat): Use it.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 5 | ||||
| -rw-r--r-- | src/w32.c | 33 |
2 files changed, 38 insertions, 0 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index dddf5447469..469bc632182 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2008-01-26 Jason Rumney <jasonr@gnu.org> | ||
| 2 | |||
| 3 | * w32.c (logon_network_drive): New function. | ||
| 4 | (stat): Use it. | ||
| 5 | |||
| 1 | 2008-01-26 Chong Yidong <cyd@stupidchicken.com> | 6 | 2008-01-26 Chong Yidong <cyd@stupidchicken.com> |
| 2 | 7 | ||
| 3 | * xdisp.c (pos_visible_p): Handle the case where charpos falls on | 8 | * xdisp.c (pos_visible_p): Handle the case where charpos falls on |
| @@ -1938,6 +1938,36 @@ unc_volume_file_attributes (const char *path) | |||
| 1938 | return attrs; | 1938 | return attrs; |
| 1939 | } | 1939 | } |
| 1940 | 1940 | ||
| 1941 | /* Ensure a network connection is authenticated. */ | ||
| 1942 | static void | ||
| 1943 | logon_network_drive (const char *path) | ||
| 1944 | { | ||
| 1945 | NETRESOURCE resource; | ||
| 1946 | char share[MAX_PATH]; | ||
| 1947 | int i, n_slashes; | ||
| 1948 | |||
| 1949 | /* Only logon to networked drives. */ | ||
| 1950 | if (!IS_DIRECTORY_SEP (path[0]) || !IS_DIRECTORY_SEP (path[1])) | ||
| 1951 | return; | ||
| 1952 | n_slashes = 2; | ||
| 1953 | strncpy (share, path, MAX_PATH); | ||
| 1954 | /* Truncate to just server and share name. */ | ||
| 1955 | for (i = 2; i < MAX_PATH; i++) | ||
| 1956 | { | ||
| 1957 | if (IS_DIRECTORY_SEP (share[i]) && ++n_slashes > 3) | ||
| 1958 | { | ||
| 1959 | share[i] = '\0'; | ||
| 1960 | break; | ||
| 1961 | } | ||
| 1962 | } | ||
| 1963 | |||
| 1964 | resource.dwType = RESOURCETYPE_DISK; | ||
| 1965 | resource.lpLocalName = NULL; | ||
| 1966 | resource.lpRemoteName = share; | ||
| 1967 | resource.lpProvider = NULL; | ||
| 1968 | |||
| 1969 | WNetAddConnection2 (&resource, NULL, NULL, CONNECT_INTERACTIVE); | ||
| 1970 | } | ||
| 1941 | 1971 | ||
| 1942 | /* Shadow some MSVC runtime functions to map requests for long filenames | 1972 | /* Shadow some MSVC runtime functions to map requests for long filenames |
| 1943 | to reasonable short names if necessary. This was originally added to | 1973 | to reasonable short names if necessary. This was originally added to |
| @@ -2495,6 +2525,9 @@ stat (const char * path, struct stat * buf) | |||
| 2495 | } | 2525 | } |
| 2496 | else | 2526 | else |
| 2497 | { | 2527 | { |
| 2528 | if (IS_DIRECTORY_SEP (name[0]) && IS_DIRECTORY_SEP (name[1])) | ||
| 2529 | logon_network_drive (name); | ||
| 2530 | |||
| 2498 | fh = FindFirstFile (name, &wfd); | 2531 | fh = FindFirstFile (name, &wfd); |
| 2499 | if (fh == INVALID_HANDLE_VALUE) | 2532 | if (fh == INVALID_HANDLE_VALUE) |
| 2500 | { | 2533 | { |