stream_t* stream_open(const char* path, size_t length, unsigned int mode) { size_t protocol_end; stream_open_fn open_fn; //Check if protocol was given protocol_end = string_find_string(path, length, STRING_CONST("://"), 0); open_fn = stream_protocol_handler((protocol_end != STRING_NPOS) ? path : "", (protocol_end != STRING_NPOS) ? protocol_end : 0); return open_fn ? open_fn(path, length, mode) : 0; }
/** * This function opens the file system stored on \p geom, if it * can find one. * It is often called in the following manner: * \code * fs = ped_file_system_open (&part.geom) * \endcode * * \throws PED_EXCEPTION_ERROR if file system could not be detected * \throws PED_EXCEPTION_ERROR if the file system is bigger than its volume * \throws PED_EXCEPTION_NO_FEATURE if opening of a file system stored on * \p geom is not implemented * * \return a PedFileSystem on success, \c NULL on failure. */ PedFileSystem * ped_file_system_open (PedGeometry* geom) { PED_ASSERT (geom != NULL); if (!ped_device_open (geom->dev)) goto error; PedFileSystemType *type = ped_file_system_probe (geom); if (!type) { ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, _("Could not detect file system.")); goto error_close_dev; } open_fn_t open_f = open_fn (type->name); if (open_f == NULL) { ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, _("resizing %s file systems is not supported"), type->name); goto error_close_dev; } PedGeometry *probed_geom = ped_file_system_probe_specific (type, geom); if (!probed_geom) goto error_close_dev; if (!ped_geometry_test_inside (geom, probed_geom)) { if (ped_exception_throw ( PED_EXCEPTION_ERROR, PED_EXCEPTION_IGNORE_CANCEL, _("The file system is bigger than its volume!")) != PED_EXCEPTION_IGNORE) goto error_destroy_probed_geom; } PedFileSystem *fs = (*open_f) (probed_geom); if (!fs) goto error_destroy_probed_geom; ped_geometry_destroy (probed_geom); fs->type = type; return fs; error_destroy_probed_geom: ped_geometry_destroy (probed_geom); error_close_dev: ped_device_close (geom->dev); error: return NULL; }
pointers operate through C Run Time (CRT) on Win32, which does all sorts of translation on them: LF's become CRLF's, and ctrl-Z's embedded in Word documents are interpreted as premature EOF's. So instead, we use apr_file_open_std*, which bypass the CRT and directly wrap the OS's file-handles, which don't know or care about translation. Thus dump/load works correctly on Win32. */ static svn_error_t * create_stdio_stream(svn_stream_t **stream, APR_DECLARE(apr_status_t) open_fn(apr_file_t **, apr_pool_t *), apr_pool_t *pool) { apr_file_t *stdio_file; apr_status_t apr_err = open_fn(&stdio_file, pool); if (apr_err) return svn_error_wrap_apr(apr_err, _("Can't open stdio file")); *stream = svn_stream_from_aprfile(stdio_file, pool); return SVN_NO_ERROR; } /* Writes a property in dumpfile format to given stringbuf. */ static void write_prop_to_stringbuf(svn_stringbuf_t **strbuf, const char *name, const svn_string_t *value) {