Compare two directory trees content.
    Return False if they differ, True is they are the same.
    :param dir2:
    :param dir1:
509377
def is_same(dir1, dir2):
    
    compared = dircmp(dir1, dir2, IGNORED_FILES)  # ignore the OS X file
    if compared.left_only or compared.right_only or compared.diff_files or compared.funny_files:
        return False
    for subdir in compared.common_dirs:
        if not is_same(os.path.join(dir1, subdir), os.path.join(dir2, subdir)):
            return False
    return True
834694
def _compare_match(dict1, dict2):
    '''
    
    '''
    for karg, warg in six.iteritems(dict1):
        if karg in dict2 and dict2[karg] != warg:
            return False
    return True
739532
def has_subdirectories(path, include, exclude, show_all):
    """"""
    try:
        # > 1 because of '..'
        return len( listdir(path, include, exclude,
                            show_all, folders_only=True) ) > 1
    except (IOError, OSError):
        return False
1364348
def samefile(file1, file2):
    # type: (str, str) -> bool
    """"""
    if hasattr(os.path, 'samefile'):
        return os.path.samefile(file1, file2)
    else:
        path1 = os.path.normcase(os.path.abspath(file1))
        path2 = os.path.normcase(os.path.abspath(file2))
        return path1 == path2
789810
def verify_dir_structure(full_path):
    '''

    '''
    if full_path == None:
        return False
    r = True
    for d2c in PREDEFINED_DIR_NAMES:
        #if d2c == "s2":
        #    d2c = ".s2"
        cp2c = os.path.join(full_path, d2c)  #complete path to check
        if not os.path.isdir(cp2c):
            r = False
            break
        else:  #exists, let's check it's writable
            if not os.access(cp2c, os.W_OK): 
                r = False
                break
    return r
1214659
def DirContains(self,f) :
        
        def match(fsNode) :
            if not fsNode.isdir() : return False 
            for c in fsNode.children() :
                if f(c) : return True
            return False
        return self.make_return(match)
145631
def mktree(newdir):
    
    if os.path.isdir(newdir):
        pass
    elif os.path.isfile(newdir):
        raise OSError("a file with the same name as the desired "
                      "dir, '%s', already exists." % newdir)
    else:
        os.makedirs(newdir)
1223340
def is_subdirectory(path_a, path_b):
    """"""
    path_a = os.path.realpath(path_a)
    path_b = os.path.realpath(path_b)
    relative = os.path.relpath(path_a, path_b)
    return (not relative.startswith(os.pardir + os.sep))
517039
def is_same_dict(d1, d2):
    
    for k, v in d1.items():
        if isinstance(v, dict):
            is_same_dict(v, d2[k])
        else:
            assert d1[k] == d2[k]

    for k, v in d2.items():
        if isinstance(v, dict):
            is_same_dict(v, d1[k])
        else:
            assert d1[k] == d2[k]
1288831
def directory_is_present(self, directory_path):
        
        p = self.p(directory_path)
        if not os.path.exists(p):
            return False
        if not os.path.isdir(p):
            raise IOError("%s is not a directory" % directory_path)
        return True
1165396
public static boolean entryEquals(File f1, File f2, String path1, String path2) {
    ZipFile zf1 = null;
    ZipFile zf2 = null;

    try {
      zf1 = new ZipFile(f1);
      zf2 = new ZipFile(f2);

      return doEntryEquals(zf1, zf2, path1, path2);
    }
    catch (IOException e) {
      throw ZipExceptionUtil.rethrow(e);
    }
    finally {
      closeQuietly(zf1);
      closeQuietly(zf2);
    }
  }
1342242
def _check_dir(self, dirname):
        
        if not os.path.exists(dirname):
            print("Directory %s does not exist!" % dirname)
            sys.exit(1)
149684
def in_same_dir(as_file, target_file):
    
    return os.path.abspath(os.path.join(os.path.dirname(as_file), target_file))
172431
def diff_dirs(dir1, dir2)
      mattching_dir_files(dir1, dir2).each do |file|
        a = File.join(dir1, file)
        b = File.join(dir2, file)
        diff_files(a,b)
      end
    end
1356187
def check_dirs():
    
    dirs = [MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR]
    for directory in dirs:
        if directory.exists() and not directory.is_dir():
            raise FileExistsError(str(directory.resolve()) + " cannot be used as a directory.")
400321
def _metatile_contents_equal(zip_1, zip_2):
    

    names_1 = set(zip_1.namelist())
    names_2 = set(zip_2.namelist())

    if names_1 != names_2:
        return False

    for n in names_1:
        bytes_1 = zip_1.read(n)
        bytes_2 = zip_2.read(n)

        if bytes_1 != bytes_2:
            return False

    return True
985100
def command_copytree(args):
    
    for srcdir in args.srcdirs:
        basename = os.path.basename(srcdir)
        destdir2 = os.path.normpath(os.path.join(args.destdir, basename))
        if os.path.exists(destdir2):
            shutil.rmtree(destdir2)
        sys.stdout.write("copytree: %s => %s\n" % (srcdir, destdir2))
        shutil.copytree(srcdir, destdir2)
    return 0