@@ -106,7 +106,7 @@ std::pair<uint64_t, uint64_t> UriLocator::decodeUriAndGetFd(UriInfo& uri,
106106 if (uri.uriPath .size () == 0 )
107107 return {0 ,0 };
108108 auto pos = uri.uriPath .find (" //" );
109- if (pos == std::string::npos || uri. uriPath . substr ( 0 , pos) != " file: " ) {
109+ if (pos == std::string::npos) {
110110 uri.uriPath =" " ;
111111 return {0 ,0 };
112112 }
@@ -126,32 +126,31 @@ std::pair<uint64_t, uint64_t> UriLocator::decodeUriAndGetFd(UriInfo& uri,
126126 else {
127127 rspos = uri.uriPath .size ()-1 ;
128128 }
129- pos += 2 ;
130- // decode filepath
131- for ( auto i=pos; i<= rspos;) {
132- cur = uri. uriPath [i];
133- if ( isalnum (cur) || cur == ' / ' || cur == ' - ' ||
134- cur == ' _' || cur == ' .' || cur == ' ~' ) {
135- ss << cur;
136- i++;
137- }
138- else {
139- // characters prefix with '%' char
140- char tbits = uri. uriPath [i+ 1 ], lbits = uri. uriPath [i+ 2 ] ;
141- uint8_t t = (tbits < 58 ) ? ( tbits - 48 ) : ((tbits - 65 ) + 10 );
142- uint8_t l = (lbits < 58 ) ? ( lbits - 48 ) : ((lbits - 65 ) + 10 );
143- ss << ( char )((( 0b00000000 | t)<< 4 ) | l) ;
144- i += 3 ;
129+ if (uri. uriPath . substr ( 0 , pos) == " file: " ) {
130+ pos += 2 ;
131+ // decode filepath
132+ for ( auto i = pos; i <= rspos;) {
133+ cur = uri. uriPath [i];
134+ if ( isalnum (cur) || cur == ' / ' || cur == ' - ' || cur == ' _' || cur == ' .' || cur == ' ~' ) {
135+ ss << cur;
136+ i++;
137+ } else {
138+ // characters prefix with '%' char
139+ char tbits = uri. uriPath [i + 1 ], lbits = uri. uriPath [i + 2 ];
140+ uint8_t t = (tbits < 58 ) ? (tbits - 48 ) : ((tbits - 65 ) + 10 ) ;
141+ uint8_t l = (lbits < 58 ) ? (lbits - 48 ) : ((lbits - 65 ) + 10 );
142+ ss << ( char )((( 0b00000000 | t) << 4 ) | l );
143+ i += 3 ;
144+ }
145145 }
146+ uri.uriPath = ss.str ();
147+ size_t fd_size;
148+ (void )amd::Os::GetFileHandle (uri.uriPath .c_str (), uri_fd, &fd_size);
149+ // As per URI locator syntax, range_specifier is optional
150+ // if range_specifier is absent return total size of the file
151+ // and set offset to begin at 0.
152+ if (size == 0 ) size = fd_size;
146153 }
147- uri.uriPath = ss.str ();
148- size_t fd_size;
149- (void ) amd::Os::GetFileHandle (uri.uriPath .c_str (), uri_fd, &fd_size);
150- // As per URI locator syntax, range_specifier is optional
151- // if range_specifier is absent return total size of the file
152- // and set offset to begin at 0.
153- if (size == 0 )
154- size = fd_size;
155154 return {offset, size};
156155}
157156
0 commit comments