FunctionPackage: common-graphicsToCDocOverviewCGDocRelNotesIndexPermutedIndex
Allegro CL version 6.2
This page is new in 6.2

network-shares

Arguments: machine

Returns a value that describes the logical filesystems that are currently offered for sharing by one or more computers in the local area network. The form of the returned value depends on the value of the machine argument. The following describes the two special cases of the machine argument (A and B), followed by the general case (C) where machine is a machine name.

Case A: machine is the keyword :connected

If machine is the keyword :connected, then a list is returned that containts one member for each share that is currently connected to the computer where the call was made, such as:

(("\\\\BEAST\\pc" "Z:")
 ("\\\\SPOT\\ACL" nil)
 ("\\\\ROMEO\\smith" nil))

where each member of the list represents a share, and is itself a list consisting of:

  1. the UNC remote name of the share (as a string) --- if you add a final slash (or backslash) to this string, or call excl:pathname-as-directory on the string, then directory can be called on the resulting value to find the files in the share; and
  2. the local name that this computer maps to this share, if any (this is typically a drive letter, such as "z:"), and otherwise nil. When non-nil, this is always a string.

Case B: machine is the keyword :all

If machine is the keyword :all, then a list is returned where there is a member for each machine that is returned by network-machines, and each of these members is a list of (1) the UNC machine name (a string) and (2) either (a) the symbol :access-denied, when that machine does not allow the current user access to its shares, or else (b) the list of shares that would be returned if machine were the machine name, as in case C. This can take a while to run, since it asks every machine in the network what its shares are.

Sample returned value:

(("\\\\ADMIN" :access-denied)
 ("\\\\BEAST"
 (("\\\\BEAST\\cdroms" "")
  ("\\\\BEAST\\support" "Support Directories")
  ("\\\\BEAST\\home1" "Home Directories")))
     ...)

Case C: machine is the UNC name of a machine

Otherwise machine should be the UNC name (a string) of a machine in the network (including the two backslashes at the front), such as "\\\\beast"; a list of all such names is returned by network-machines. In this case, either (1) the symbol :access-denied is returned, if the machine will not allow the current user access to its shares, or (2) a list of that machine's shares is returned, where each share is a list of: (a) the UNC name of the share, such as "\\\\beast\\pc", and (b) the "comment" for the share (which is always a string).

Example: The following expression would find an accessible share and return a list of its name and the top-level files in it:

(dolist (machine (network-machines))
  (let* ((shares (network-shares (first machine))))
    (unless (or (null shares)
		(eq shares :access-denied))
      (let* ((directory-name (concatenate 'string
			       (caar shares)
			       "/")))
	(return (list directory-name
		      (directory directory-name)))))))

Currently this function is in the Common Graphics module and package, and is implemented only on the Windows platform. It will probably be moved into the Windows module and package, or possibly elsewhere if it is implemented for Unix as well. This function is used by ask-user-for-new-or-existing-directory.

Implementation note: On Windows, this function returns information as provided by the function WNetEnumResource in the Windows Networking (WNet) area of the Windows API.


Copyright (c) 1998-2002, Franz Inc. Oakland, CA., USA. All rights reserved.
Documentation for Allegro CL version 6.2. This page is new in the 6.2 release.
Created 2002.2.26.

ToCDocOverviewCGDocRelNotesIndexPermutedIndex
Allegro CL version 6.2
This page is new in 6.2