Add 'IsRemotePath' to Util

This commit is contained in:
Jaidyn Ann 2020-11-16 18:46:07 -06:00
parent 23db715ed8
commit 12368433cd
3 changed files with 19 additions and 3 deletions

View File

@ -1,4 +1,4 @@
// borrowed significantly from mailserver. thanks! <3 // borrowed significantly (addAttribute) from mailserver. thanks! <3
#include <iostream> #include <iostream>
#include <Application.h> #include <Application.h>
#include <DateTime.h> #include <DateTime.h>
@ -6,6 +6,7 @@
#include <MimeType.h> #include <MimeType.h>
#include "Mimetypes.h" #include "Mimetypes.h"
// install the Feed Entry mimetype, if need be
bool bool
feedMimeType ( ) feedMimeType ( )
{ {
@ -25,12 +26,12 @@ feedMimeType ( )
addAttribute( info, "FEED:source", "Source" ); addAttribute( info, "FEED:source", "Source" );
addAttribute( info, "FEED:when", "When", B_TIME_TYPE, 150 ); addAttribute( info, "FEED:when", "When", B_TIME_TYPE, 150 );
mime.SetAttrInfo( &info ); return mime.SetAttrInfo( &info );
return true;
} }
// ------------------------------------- // -------------------------------------
// add the given attribute to a BMessage for use as attr info
static void static void
addAttribute addAttribute
( BMessage& msg, const char* name, const char* publicName, int32 type, int32 width ) ( BMessage& msg, const char* name, const char* publicName, int32 type, int32 width )

View File

@ -73,6 +73,19 @@ withinDateRange ( BDateTime minDate, BDateTime nowDate, BDateTime maxDate )
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// return whether or not the given path is remote
bool
isRemotePath ( BString path ) {
BUrl givenUrl = BUrl( path );
BString protocol = givenUrl.Protocol().String();
if ( protocol == NULL || protocol == BString("file") || givenUrl.UrlString() == NULL )
return false;
return true;
}
// ----------------------------------------------------------------------------
int32 int32
webFetch ( BUrl url, BDataIO* reply ) webFetch ( BUrl url, BDataIO* reply )
{ {

View File

@ -14,6 +14,8 @@ BString dateTo3339String ( BDateTime );
bool withinDateRange ( BDateTime, BDateTime, BDateTime ); bool withinDateRange ( BDateTime, BDateTime, BDateTime );
bool isRemotePath ( BString );
int32 webFetch ( BUrl, BDataIO*, BString* ); int32 webFetch ( BUrl, BDataIO*, BString* );
int32 webFetch ( BUrl, BDataIO* ); int32 webFetch ( BUrl, BDataIO* );