\HeaderA{findCdf}{Search for CDF files in multiple directories}{findCdf}
\keyword{file}{findCdf}
\keyword{IO}{findCdf}
\begin{Description}\relax
Search for CDF files in multiple directories.
\end{Description}
\begin{Usage}
\begin{verbatim}findCdf(chipType=NULL, paths=NULL, pattern="[.](c|C)(d|D)(f|F)$", ...)\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{chipType}] A \code{\LinkA{character}{character}} string of the chip type to search for.
\item[\code{paths}] A \code{\LinkA{character}{character}} \code{\LinkA{vector}{vector}} of paths to be searched.
The current directory is always searched at the beginning.
If \code{\LinkA{NULL}{NULL}}, default paths are searched.  For more details, see below.
\item[\code{pattern}] A regular expression file name pattern to match.
\item[\code{...}] Additional arguments passed to \code{\LinkA{findFiles}{findFiles}}().
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
Note, the current directory is always searched at the beginning.
This provides an easy way to override other files in the search path.
If \code{paths} is \code{\LinkA{NULL}{NULL}}, then a set of default paths are searched.
The default search path is consituted of:
\Enumerate{
\item \code{"."}
\item \code{"cdf/;data/cdf/"}
\item \code{getOption("AFFX\_CDF\_PATH")}
\item \code{Sys.getenv("AFFX\_CDF\_PATH")}
}

One of the easiest ways to set system variables for \R{} is to
set them in an \code{.Renviron} file, e.g.
\begin{alltt}
    \# affxparser: Set default CDF path
    AFFX\_CDF\_PATH=\$\{AFFX\_CDF\_PATH\};M:/Affymetrix\_2004-100k\_trios/cdf
    AFFX\_CDF\_PATH=\$\{AFFX\_CDF\_PATH\};M:/Affymetrix\_2005-500k\_data/cdf
\end{alltt}
See \code{\LinkA{Startup}{Startup}} for more details.
\end{Details}
\begin{Value}
Returns a \code{\LinkA{vector}{vector}} of the full pathnames of the files found.
\end{Value}
\begin{Author}\relax
Henrik Bengtsson (\url{http://www.braju.com/R/})
\end{Author}
\begin{SeeAlso}\relax
This method is used internally by \code{\LinkA{readCelUnits}{readCelUnits}}() if the CDF
file is not specified.
\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}

# Find a specific CDF file
cdfFile <- findCdf("Mapping50K_Xba240")
print(cdfFile)

# Find the first CDF file (no matter what it is)
cdfFile <- findCdf()
print(cdfFile)

# Find all CDF files in search path and display their headers
cdfFiles <- findCdf(firstOnly=FALSE)
for (cdfFile in cdfFiles) {
  cat("=======================================\n")
  hdr <- readCdfHeader(cdfFile)
  str(hdr)
}
\end{ExampleCode}
\end{Examples}

