9
9
// Use of this source code is governed by the UniDoc End User License Agreement
10
10
// terms that can be accessed at https://unidoc.io/eula/
11
11
12
- package content ;import (_f "archive/zip" ;_ca "bytes" ;_fc "encoding/json" ;_a "golang.org/x/xerrors" ;_g "io/ioutil" ;_bd "net/url" ;_d "os" ;_b "strings" ;);
12
+ package content ;import (_b "archive/zip" ;_g "bytes" ;_ce "encoding/json" ;_cgc "golang.org/x/xerrors" ;_e "io/ioutil" ;_cg "net/url" ;_dc "os" ;_d "strings" ;);func (_bgd * zipDirectory )zipPath (_ef ,_db string )error {_bc ,_ae := _e .ReadDir (_ef );if _ae != nil {return _cgc .Errorf ("\u0072 \u0065 \u0061 di\u006e \u0067 \u0020 \u0064 \u0069 \u0072 \u0065 \u0063 \u0074 o\u0072 y\u003a \u0027 %\u0073 \u0027 \u0020 \u0066 \u0061 \u0069 \u006c \u0065 \u0064 \u003a \u0020 \u0025 \u0077 " ,_ef ,_ae );
13
+ };_bcf := & _d .Builder {};for _ ,_gb := range _bc {_bb ,_cgd := _bgd .zipBasePaths (_gb ,_ef ,_db ,_gb .IsDir (),_bcf );if _gb .IsDir (){if _cbc := _bgd .zipPath (_bb ,_cgd );_cbc != nil {return _cbc ;};continue ;};_dg ,_ee := _e .ReadFile (_bb );if _ee != nil {return _ee ;
14
+ };_bce ,_ee := _bgd ._cgae .Create (_cgd );if _ee != nil {return _ee ;};if _ ,_ee = _bce .Write (_dg );_ee != nil {return _ee ;};};return nil ;};
13
15
14
16
// NewHTMLFile creates new Content htmFile for provided input path.
15
- func NewHTMLFile (path string )(Content ,error ){_cad , _ag := _d .Open (path );if _ag != nil {return nil ,_ag ;};_df := & htmFile {_cf :_ca .Buffer {}};if _ ,_ag = _df . _cf .ReadFrom (_cad );_ag != nil {return nil ,_ag ;};return _df ,nil ;};
17
+ func NewHTMLFile (path string )(Content ,error ){_f , _ed := _dc .Open (path );if _ed != nil {return nil ,_ed ;};_gc := & htmFile {_cb :_g .Buffer {}};if _ ,_ed = _gc . _cb .ReadFrom (_f );_ed != nil {return nil ,_ed ;};return _gc ,nil ;};
16
18
17
19
// ContentType implements Content interface.
18
- func (_ce * webURL )ContentType ()string {return "\u0061 \u0070 p \u006c \u0069 \u0063 a \ u0074\u0069 \u006f \u006e \ u002f\u006a \u0073 \u006f \u006e " ; };
20
+ func (_bg * htmFile )ContentType ()string {return "\u0074 e \u0078 \ u0074\u002f \u0068 \u0074 \u006d l" };
19
21
20
- // NewWebURL creates new Content webURL for provided input URL path.
21
- func NewWebURL (path string )(Content ,error ){if _ ,_aa := _bd .Parse (path );_aa != nil {return nil ,_aa ;};type urlOutput struct {URL string `json:"url"` ;};_cb := urlOutput {URL :path };_e ,_ae := _fc .Marshal (_cb );if _ae != nil {return nil ,_ae ;};return & webURL {_bb :path ,_fg :_e },nil ;
22
- };type webURL struct {_bb string ;_fg []byte ;};
22
+ // Data implements Content interface.
23
+ func (_cbb * htmFile )Data ()[]byte {return _cbb ._cb .Bytes ()};
23
24
24
25
// Data implements Content interface.
25
- func (_ggd * webURL )Data ()[]byte {return _ggd ._fg };
26
+ func (_ba * webURL )Data ()[]byte {return _ba ._gd };type webURL struct {_a string ;_gd []byte ;};func (_dgf * zipDirectory )zipBasePaths (_ga _dc .FileInfo ,_fac ,_gbg string ,_fag bool ,_cbf * _d .Builder )(string ,string ){_cbf .WriteString (_fac );if ! _d .HasSuffix (_fac ,"\u002f " ){_cbf .WriteRune ('/' );
27
+ };_cbf .WriteString (_ga .Name ());if _fag {_cbf .WriteRune ('/' );};_de := _cbf .String ();_cbf .Reset ();_cbf .WriteString (_gbg );_cbf .WriteString (_ga .Name ());if _fag {_cbf .WriteRune ('/' );};_eg := _cbf .String ();_cbf .Reset ();return _de ,_eg ;};
26
28
27
- // ContentType implements Content interface.
28
- func (_ab * zipDirectory )ContentType ()string {return "\u0061 p\u0070 l\u0069 \u0063 \u0061 \u0074 \u0069 \u006f \u006e \u002f \u007a \u0069 \u0070 " ;};
29
29
30
- // Data implements Content interface.
31
- func (_gf * htmFile )Data ()[]byte {return _gf ._cf .Bytes ()};type htmFile struct {_cf _ca .Buffer };
30
+ // NewWebURL creates new Content webURL for provided input URL path.
31
+ func NewWebURL (path string )(Content ,error ){if _ ,_bf := _cg .Parse (path );_bf != nil {return nil ,_bf ;};type urlOutput struct {URL string `json:"url"` ;};_da := urlOutput {URL :path };_be ,_bd := _ce .Marshal (_da );if _bd != nil {return nil ,_bd ;};return & webURL {_a :path ,_gd :_be },nil ;
32
+ };
32
33
33
34
// NewZipDirectory creates new zip compressed file that recursively reads the directory at the 'dirPath'
34
35
// and stores in it's in-memory buffer.
35
- func NewZipDirectory (dirPath string )(Content ,error ){_bc := & zipDirectory {_bf :_ca .Buffer {}};_bc ._cba = _f .NewWriter (& _bc ._bf );if _gff := _bc .zipPath (dirPath ,"" );_gff != nil {return nil ,_gff ;};if _ad := _bc ._cba .Close ();_ad != nil {return nil ,_ad ;
36
- };return _bc ,nil ;};
37
-
38
- // ContentType implements Content interface.
39
- func (_gg * htmFile )ContentType ()string {return "\u0074 e\u0078 \u0074 \u002f \u0068 \u0074 \u006d l" };
36
+ func NewZipDirectory (dirPath string )(Content ,error ){_eb := & zipDirectory {_cga :_g .Buffer {}};_eb ._cgae = _b .NewWriter (& _eb ._cga );if _fed := _eb .zipPath (dirPath ,"" );_fed != nil {return nil ,_fed ;};if _dd := _eb ._cgae .Close ();_dd != nil {return nil ,_dd ;
37
+ };return _eb ,nil ;};
40
38
41
39
// Content is an interface used for putting the content into Client Query.
42
- type Content interface {ContentType ()string ;Data ()[]byte ;};func (_cc * zipDirectory )zipBasePaths (_fbc _d .FileInfo ,_aeb ,_dgg string ,_ec bool ,_abe * _b .Builder )(string ,string ){_abe .WriteString (_aeb );if ! _b .HasSuffix (_aeb ,"\u002f " ){_abe .WriteRune ('/' );
43
- };_abe .WriteString (_fbc .Name ());if _ec {_abe .WriteRune ('/' );};_bfg := _abe .String ();_abe .Reset ();_abe .WriteString (_dgg );_abe .WriteString (_fbc .Name ());if _ec {_abe .WriteRune ('/' );};_gc := _abe .String ();_abe .Reset ();return _bfg ,_gc ;
44
- };func (_dde * zipDirectory )zipPath (_aed ,_de string )error {_ded ,_dg := _g .ReadDir (_aed );if _dg != nil {return _a .Errorf ("\u0072 \u0065 \u0061 di\u006e \u0067 \u0020 \u0064 \u0069 \u0072 \u0065 \u0063 \u0074 o\u0072 y\u003a \u0027 %\u0073 \u0027 \u0020 \u0066 \u0061 \u0069 \u006c \u0065 \u0064 \u003a \u0020 \u0025 \u0077 " ,_aed ,_dg );
45
- };_add := & _b .Builder {};for _ ,_cfd := range _ded {_ceg ,_fb := _dde .zipBasePaths (_cfd ,_aed ,_de ,_cfd .IsDir (),_add );if _cfd .IsDir (){if _ea := _dde .zipPath (_ceg ,_fb );_ea != nil {return _ea ;};continue ;};_bfb ,_gfg := _g .ReadFile (_ceg );if _gfg != nil {return _gfg ;
46
- };_cd ,_gfg := _dde ._cba .Create (_fb );if _gfg != nil {return _gfg ;};if _ ,_gfg = _cd .Write (_bfb );_gfg != nil {return _gfg ;};};return nil ;};type zipDirectory struct {_bf _ca .Buffer ;_cba * _f .Writer ;};
40
+ type Content interface {ContentType ()string ;Data ()[]byte ;};
41
+
42
+ // ContentType implements Content interface.
43
+ func (_df * zipDirectory )ContentType ()string {return "\u0061 p\u0070 l\u0069 \u0063 \u0061 \u0074 \u0069 \u006f \u006e \u002f \u007a \u0069 \u0070 " ;};type zipDirectory struct {_cga _g .Buffer ;_cgae * _b .Writer ;};type htmFile struct {_cb _g .Buffer };
47
44
48
45
// Data implements Content interface.
49
- func (_bdc * zipDirectory )Data ()[]byte {return _bdc ._bf .Bytes ()};
46
+ func (_fa * zipDirectory )Data ()[]byte {return _fa ._cga .Bytes ()};
47
+
48
+ // ContentType implements Content interface.
49
+ func (_bgc * webURL )ContentType ()string {return "\u0061 \u0070 p\u006c \u0069 \u0063 a\u0074 \u0069 \u006f \u006e \u002f \u006a \u0073 \u006f \u006e " ;};
0 commit comments