Blame src/FileGlob.h

Packit 8f70b4
/*
Packit 8f70b4
 * lftp - file transfer program
Packit 8f70b4
 *
Packit 8f70b4
 * Copyright (c) 1996-2017 by Alexander V. Lukyanov (lav@yars.free.net)
Packit 8f70b4
 *
Packit 8f70b4
 * This program is free software; you can redistribute it and/or modify
Packit 8f70b4
 * it under the terms of the GNU General Public License as published by
Packit 8f70b4
 * the Free Software Foundation; either version 3 of the License, or
Packit 8f70b4
 * (at your option) any later version.
Packit 8f70b4
 *
Packit 8f70b4
 * This program is distributed in the hope that it will be useful,
Packit 8f70b4
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 8f70b4
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 8f70b4
 * GNU General Public License for more details.
Packit 8f70b4
 *
Packit 8f70b4
 * You should have received a copy of the GNU General Public License
Packit 8f70b4
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
Packit 8f70b4
 */
Packit 8f70b4
Packit 8f70b4
#ifndef GLOB_H
Packit 8f70b4
#define GLOB_H
Packit 8f70b4
Packit 8f70b4
#include "FileAccess.h"
Packit 8f70b4
Packit 8f70b4
class Glob : public FileAccessOperation
Packit 8f70b4
{
Packit 8f70b4
protected:
Packit 8f70b4
   xstring_c pattern;
Packit 8f70b4
   FileSet list;
Packit 8f70b4
   bool	 dirs_only;
Packit 8f70b4
   bool	 files_only;
Packit 8f70b4
   bool	 match_period;
Packit 8f70b4
   bool	 inhibit_tilde;
Packit 8f70b4
   bool	 casefold;
Packit 8f70b4
   void	 add(const FileInfo *info);
Packit 8f70b4
   void	 add_force(const FileInfo *info);
Packit 8f70b4
public:
Packit 8f70b4
   const char *GetPattern() { return pattern; }
Packit 8f70b4
   FileSet *GetResult() { return &list; }
Packit 8f70b4
   Glob(FileAccess *s,const char *p);
Packit 8f70b4
   ~Glob();
Packit 8f70b4
   void DirectoriesOnly() { dirs_only=true; }
Packit 8f70b4
   void FilesOnly() { files_only=true; }
Packit 8f70b4
   void NoMatchPeriod() { match_period=false; }
Packit 8f70b4
   void NoInhibitTilde() { inhibit_tilde=false; }
Packit 8f70b4
   void CaseFold() { casefold=true; }
Packit 8f70b4
Packit 8f70b4
   void MatchPeriod(bool y) { match_period=y; }
Packit 8f70b4
   void InhibitTilde(bool y) { inhibit_tilde=y; }
Packit 8f70b4
   void CaseFold(bool y) { casefold=y; }
Packit 8f70b4
Packit 8f70b4
   static bool HasWildcards(const char *);
Packit 8f70b4
   static void UnquoteWildcards(char *);
Packit 8f70b4
};
Packit 8f70b4
class NoGlob : public Glob
Packit 8f70b4
{
Packit 8f70b4
public:
Packit 8f70b4
   NoGlob(const char *p);
Packit 8f70b4
   const char *Status() { return ""; }
Packit 8f70b4
   int Do();
Packit 8f70b4
};
Packit 8f70b4
class GlobURL
Packit 8f70b4
{
Packit 8f70b4
   const FileAccessRef& orig_session;
Packit 8f70b4
   FileAccessRef my_session;
Packit 8f70b4
   FileAccessRefC session;
Packit 8f70b4
   xstring_c url_prefix;
Packit 8f70b4
   bool nullglob;
Packit 8f70b4
public:
Packit 8f70b4
   SMTaskRef<Glob> glob;
Packit 8f70b4
Packit 8f70b4
   enum type_select
Packit 8f70b4
   {
Packit 8f70b4
      ALL,
Packit 8f70b4
      FILES_ONLY,
Packit 8f70b4
      DIRS_ONLY
Packit 8f70b4
   };
Packit 8f70b4
Packit 8f70b4
   GlobURL(const FileAccessRef& s,const char *p,type_select t=ALL);
Packit 8f70b4
   ~GlobURL();
Packit 8f70b4
   FileSet *GetResult();
Packit 8f70b4
   bool Done()  { return glob->Done(); }
Packit 8f70b4
   bool Error() { return glob->Error(); }
Packit 8f70b4
   const char *ErrorText() { return glob->ErrorText(); }
Packit 8f70b4
   const char *Status() { return glob->Status(); }
Packit 8f70b4
Packit 8f70b4
   void NewGlob(const char *p);
Packit 8f70b4
   const char *GetPattern() { return glob->GetPattern(); }
Packit 8f70b4
Packit 8f70b4
   void NoMatchPeriod()	   { if(glob) glob->NoMatchPeriod(); }
Packit 8f70b4
   void NoInhibitTilde()   { if(glob) glob->NoInhibitTilde(); }
Packit 8f70b4
   void CaseFold()	   { if(glob) glob->CaseFold(); }
Packit 8f70b4
   void NullGlob(bool y=true) { nullglob=y; }
Packit 8f70b4
Packit 8f70b4
private:
Packit 8f70b4
   type_select type;
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
class GenericGlob : public Glob
Packit 8f70b4
{
Packit 8f70b4
   const char *curr_dir;
Packit 8f70b4
   FileSet *dir_list;
Packit 8f70b4
   SMTaskRef<Glob> updir_glob;
Packit 8f70b4
   SMTaskRef<ListInfo> li;
Packit 8f70b4
Packit 8f70b4
public:
Packit 8f70b4
   int	 Do();
Packit 8f70b4
   const char *Status();
Packit 8f70b4
Packit 8f70b4
   GenericGlob(FileAccess *session,const char *n_pattern);
Packit 8f70b4
};
Packit 8f70b4
Packit 8f70b4
#endif