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 (_dc "archive/zip" ;_b "bytes" ;_e "fmt" ;_ga "net/url" ;_df "os" ;_g "strings" ;);
13
-
14
- // NewWebURL creates new Content webURL for provided input URL path.
15
- func NewWebURL (path string )(Content ,error ){if _ ,_dcf := _ga .Parse (path );_dcf != nil {return nil ,_dcf ;};return & webURL {_cb :path },nil ;};
12
+ package content ;import (_ea "archive/zip" ;_d "bytes" ;_fa "fmt" ;_ec "net/url" ;_fg "os" ;_f "strings" ;);
16
13
17
14
// ContentType implements Content interface.
18
- func (_dea * zipDirectory )ContentType ()string {return "\u0061 p\u0070 l\u0069 \u0063 \u0061 \u0074 \u0069 \u006f \u006e \u002f \u007a \u0069 \u0070 " ;};
19
-
20
- // Content is an interface used for putting the content into Client Query.
21
- type Content interface {ContentType ()string ;Method ()string ;Data ()[]byte ;};
22
-
23
- // Data implements Content interface.
24
- func (_gef * StringContent )Data ()[]byte {return []byte (_gef ._ae )};
15
+ func (_fe * webURL )ContentType ()string {return "\u0074 \u0065 \u0078 \u0074 \u002f \u0070 \u006c \u0061 \u0069 \u006e " ;};
25
16
26
17
// ContentType implements Content interface.
27
- func (_ac * StringContent )ContentType ()string {return "\u0074 e \u0078 \ u0074\u002f \u0068 \u0074 \u006d l" };
18
+ func (_cg * zipDirectory )ContentType ()string {return "\u0061 p \u0070 l \u0069 \u0063 \u0061 \ u0074\u0069 \u006f \u006e \ u002f\u007a \u0069 \u0070 " ;}; type htmlFile struct { _c _d . Buffer };
28
19
29
- // Data implements Content interface.
30
- func (_gd * webURL ) Data ()[] byte {return [] byte ( _gd . _cb ) };
20
+ // Method implements Content interface.
21
+ func (_gce * StringContent ) Method ()string {return " \u0068 \u0074 \u006d \u006c " };
31
22
32
- // Data implements Content interface.
33
- func (_ca * htmlFile )Data ()[]byte {return _ca ._bc .Bytes ()};type htmlFile struct {_bc _b .Buffer };func (_bg * zipDirectory )zipPath (_gf ,_eg string )error {_bfa ,_bfdb := _df .ReadDir (_gf );if _bfdb != nil {return _e .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 " ,_gf ,_bfdb );
34
- };_gfg := & _g .Builder {};for _ ,_bcb := range _bfa {_db ,_aa := _bcb .Info ();if _aa != nil {return _aa ;};_aaf ,_fge := _bg .zipBasePaths (_db ,_gf ,_eg ,_bcb .IsDir (),_gfg );if _bcb .IsDir (){if _ge := _bg .zipPath (_aaf ,_fge );_ge != nil {return _ge ;};
35
- continue ;};_fb ,_aa := _df .ReadFile (_aaf );if _aa != nil {return _aa ;};_ebe ,_aa := _bg ._a .Create (_fge );if _aa != nil {return _aa ;};if _ ,_aa = _ebe .Write (_fb );_aa != nil {return _aa ;};};return nil ;};
23
+ // Method gets the web url query method.
24
+ func (_ff * webURL )Method ()string {return "\u0077 \u0065 \u0062 " };type webURL struct {_ee string };
36
25
37
- // Data implements Content interface .
38
- func ( _ebf * zipDirectory ) Data ()[] byte { return _ebf . _gae . Bytes () };
26
+ // NewWebURL creates new Content webURL for provided input URL path .
27
+ func NewWebURL ( path string )( Content , error ){ if _ , _dd := _ec . Parse ( path ); _dd != nil { return nil , _dd ;}; return & webURL { _ee : path }, nil ; };
39
28
40
- // Method gets the web url query method .
41
- func ( _eb * webURL ) Method ()string { return " \u0077 \u0065 \u0062 " };
29
+ // Content is an interface used for putting the content into Client Query .
30
+ type Content interface { ContentType () string ; Method ()string ; Data ()[] byte ; };
42
31
43
- // StringContent implements Content interface for an HTML string.
44
- type StringContent struct {_ae string };
32
+ // ContentType implements Content interface.
33
+ func (_ca * htmlFile )ContentType ()string {return "\u0074 e\u0078 \u0074 \u002f \u0068 \u0074 \u006d l" };func (_ge * zipDirectory )zipPath (_gd ,_gc string )error {_egf ,_gbg := _fg .ReadDir (_gd );if _gbg != nil {return _fa .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 " ,_gd ,_gbg );
34
+ };_dde := & _f .Builder {};for _ ,_fc := range _egf {_ae ,_bg := _fc .Info ();if _bg != nil {return _bg ;};_fb ,_ed := _ge .zipBasePaths (_ae ,_gd ,_gc ,_fc .IsDir (),_dde );if _fc .IsDir (){if _bf := _ge .zipPath (_fb ,_ed );_bf != nil {return _bf ;};continue ;
35
+ };_dab ,_bg := _fg .ReadFile (_fb );if _bg != nil {return _bg ;};_fce ,_bg := _ge ._gb .Create (_ed );if _bg != nil {return _bg ;};if _ ,_bg = _fce .Write (_dab );_bg != nil {return _bg ;};};return nil ;};
45
36
46
37
// NewZipDirectory creates new zip compressed file that recursively reads the directory at the 'dirPath'
47
38
// and stores in it's in-memory buffer.
48
- func NewZipDirectory (dirPath string )(Content ,error ){_bcc := & zipDirectory {_gae :_b .Buffer {}};_bcc . _a = _dc .NewWriter (& _bcc . _gae );if _gac := _bcc .zipPath (dirPath ,"" );_gac != nil {return nil ,_gac ;};if _ad := _bcc . _a .Close ();_ad != nil {return nil ,_ad ;
49
- };return _bcc ,nil ;};
39
+ func NewZipDirectory (dirPath string )(Content ,error ){_db := & zipDirectory {_cb :_d .Buffer {}};_db . _gb = _ea .NewWriter (& _db . _cb );if _cag := _db .zipPath (dirPath ,"" );_cag != nil {return nil ,_cag ;};if _de := _db . _gb .Close ();_de != nil {return nil ,_de ;
40
+ };return _db ,nil ;};
50
41
51
- // NewHTMLFile creates new Content htmFile for provided input path.
52
- func NewHTMLFile (path string )(Content ,error ){_de ,_ea := _df .Open (path );if _ea != nil {return nil ,_ea ;};_bf := & htmlFile {_bc :_b .Buffer {}};if _ ,_ea = _bf ._bc .ReadFrom (_de );_ea != nil {return nil ,_ea ;};return _bf ,nil ;};
42
+ // Data implements Content interface.
43
+ func (_b * htmlFile )Data ()[]byte {return _b ._c .Bytes ()};
44
+
45
+ // NewStringContent creates a new StringContent.
46
+ func NewStringContent (html string )(* StringContent ,error ){return & StringContent {_faa :html },nil };
53
47
54
48
// Method gets the query method.
55
- func (_f * htmlFile )Method ()string {return "\u0068 \u0074 \u006d \u006c " }; type zipDirectory struct { _gae _b . Buffer ; _a * _dc . Writer ; };
49
+ func (_g * htmlFile )Method ()string {return "\u0068 \u0074 \u006d \u006c " };
56
50
57
- // ContentType implements Content interface.
58
- func ( _bfd * htmlFile ) ContentType () string { return " \u0074 e \u0078 \u0074 \u002f \u0068 \u0074 \u006d l" };func (_fa * zipDirectory )zipBasePaths (_eaf _df .FileInfo ,_dfa , _cc string ,_ce bool ,_be * _g .Builder )(string ,string ){_be .WriteString (_dfa );if ! _g .HasSuffix (_dfa ,"\u002f " ){_be .WriteRune ('/' );
59
- };_be .WriteString (_eaf .Name ());if _ce { _be .WriteRune ('/' );};_faa := _be .String ();_be .Reset ();_be .WriteString (_cc );_be .WriteString (_eaf .Name ());if _ce { _be .WriteRune ('/' );};_ag := _be .String ();_be .Reset ();return _faa , _ag ;}; type webURL struct { _cb string };
51
+ // StringContent implements Content interface for an HTML string .
52
+ type StringContent struct { _faa string }; type zipDirectory struct { _cb _d . Buffer ; _gb * _ea . Writer ; };func (_cgc * zipDirectory )zipBasePaths (_fgf _fg .FileInfo ,_bfc , _dc string ,_ac bool ,_cd * _f .Builder )(string ,string ){_cd .WriteString (_bfc );if ! _f .HasSuffix (_bfc ,"\u002f " ){_cd .WriteRune ('/' );
53
+ };_cd .WriteString (_fgf .Name ());if _ac { _cd .WriteRune ('/' );};_ce := _cd .String ();_cd .Reset ();_cd .WriteString (_dc );_cd .WriteString (_fgf .Name ());if _ac { _cd .WriteRune ('/' );};_aec := _cd .String ();_cd .Reset ();return _ce , _aec ; };
60
54
55
+ // Data implements Content interface.
56
+ func (_ag * webURL )Data ()[]byte {return []byte (_ag ._ee )};
61
57
62
58
// ContentType implements Content interface.
63
- func (_dfb * webURL )ContentType ()string {return "\u0074 \u0065 \ u0078\u0074 \u002f \u0070 \u006c \u0061 \u0069 \u006e " ; };
59
+ func (_eb * StringContent )ContentType ()string {return "\u0074 e \ u0078\u0074 \u002f \u0068 \u0074 \u006d l" };
64
60
65
- // NewStringContent creates a new StringContent .
66
- func NewStringContent ( html string )( * StringContent , error ) {return & StringContent { _ae : html }, nil };
61
+ // Method gets the zip directory method .
62
+ func ( _eg * zipDirectory ) Method () string {return " \u0064 \u0069 \u0072 " };
67
63
68
- // Method implements Content interface .
69
- func ( _bd * StringContent ) Method () string {return " \u0068 \u0074 \u006d \u006c " };
64
+ // NewHTMLFile creates new Content htmFile for provided input path .
65
+ func NewHTMLFile ( path string )( Content , error ){ _a , _dg := _fg . Open ( path ); if _dg != nil {return nil , _dg ;}; _cf := & htmlFile { _c :_d . Buffer {}}; if _ , _dg = _cf . _c . ReadFrom ( _a ); _dg != nil { return nil , _dg ;}; return _cf , nil ; };
70
66
71
- // Method gets the zip directory method.
72
- func (_bb * zipDirectory )Method ()string {return "\u0064 \u0069 \u0072 " };
67
+ // Data implements Content interface.
68
+ func (_abd * zipDirectory )Data ()[]byte {return _abd ._cb .Bytes ()};
69
+
70
+ // Data implements Content interface.
71
+ func (_fab * StringContent )Data ()[]byte {return []byte (_fab ._faa )};
0 commit comments