- <S3Path> <LocalPath> - <LocalPath> <S3Path> TODO - <S3Path> <S3Path> - <S3Path> <S3Bucket> - <LocalDir> <S3Bucket> Added a new package called 'URI' for parsing URI schemes in standard way.
47 lines
1.1 KiB
Go
47 lines
1.1 KiB
Go
/*
|
|
* Mini Object Storage, (C) 2014,2015 Minio, Inc.
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
package uri
|
|
|
|
// #include <stdlib.h>
|
|
// #include "uri.h"
|
|
import "C"
|
|
import "unsafe"
|
|
|
|
type URI struct {
|
|
Scheme string
|
|
Server string
|
|
Path string
|
|
}
|
|
|
|
func ParseURI(url string) (uri *URI) {
|
|
var buri *C.bURI
|
|
ret := C.minio_uri_parse(C.CString(url), &buri)
|
|
defer C.free(unsafe.Pointer(buri))
|
|
|
|
uri = &URI{Scheme: "", Server: "", Path: ""}
|
|
if int(ret) == -1 {
|
|
// URI cannot be parsed
|
|
return
|
|
}
|
|
|
|
uri.Scheme = C.GoString(buri.scheme)
|
|
uri.Server = C.GoString(buri.server)
|
|
uri.Path = C.GoString(buri.path)
|
|
|
|
return
|
|
}
|