github.com/hanwen/go-fuse@v1.0.0/example/multizip/main.go (about)

     1  // Copyright 2016 the Go-FUSE Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  package main
     6  
     7  import (
     8  	"flag"
     9  	"fmt"
    10  	"os"
    11  	"path/filepath"
    12  
    13  	"github.com/hanwen/go-fuse/fuse/nodefs"
    14  	"github.com/hanwen/go-fuse/fuse/pathfs"
    15  	"github.com/hanwen/go-fuse/zipfs"
    16  )
    17  
    18  func main() {
    19  	// Scans the arg list and sets up flags
    20  	debug := flag.Bool("debug", false, "debug on")
    21  	flag.Parse()
    22  	if flag.NArg() < 1 {
    23  		_, prog := filepath.Split(os.Args[0])
    24  		fmt.Printf("usage: %s MOUNTPOINT\n", prog)
    25  		os.Exit(2)
    26  	}
    27  
    28  	fs := zipfs.NewMultiZipFs()
    29  	nfs := pathfs.NewPathNodeFs(fs, nil)
    30  	opts := nodefs.NewOptions()
    31  	opts.Debug = *debug
    32  	state, _, err := nodefs.MountRoot(flag.Arg(0), nfs.Root(), opts)
    33  	if err != nil {
    34  		fmt.Printf("Mount fail: %v\n", err)
    35  		os.Exit(1)
    36  	}
    37  
    38  	state.Serve()
    39  }