can I open a file in a URL?

for example:

fopen("","r")

Will this one work?

If not, what are the other alternatives in opening a file in the URL..

thanks...

Dani AI

Generated

Standard C file I/O talks to the local filesystem; it does not implement network protocols such as svn:// or http://. When the program and the repository files are checked out together (the situation described later by ), treating those files as ordinary local files is the simplest and most reliable approach — no network-layer handling is needed.

When a direct checkout is not available, common options are:

  • Stream the file with the Subversion client and read the output (simple, quick to implement). Example command:

    svn cat svn://server/repo/path/file.txt

    That output can be captured by a pipe (popen or equivalent) so the program consumes the file contents without implementing the SVN protocol itself. The CLI handles authentication and server interaction.

  • Embed the Subversion client libraries (libsvn) in the program for direct programmatic access. This is the most robust solution for tight integration but requires linking APR/Serf and learning the Subversion APIs.

  • If the repository is exposed over HTTP(S), use an HTTP client library or the platform HTTP APIs (a protocol-aware client is required for HTTP access).

Practical notes and troubleshooting: confirm the repository protocol before choosing a method; CLI-based approaches require the svn binary and will use cached credentials or prompt for them; Subversion libraries require credential callbacks. For repeatable builds, prefer checking out or using svn export at build time so runtime code reads plain files. Authoritative documentation and API details are available in the official Subversion resources: Version Control with Subversion and Apache Subversion.

Recommended Answers

All 4 Replies

If it were that easy, you'd be having A LOT less network glitches when playing online... :p Although you're right, network connections do work like files, in that you can use read and write to write over network sockets.

Enough blab, if you want easy downloading of web pages, head over to libcurl. Or if you actually want to open a network socket and see the technical details of it, see here.

i am trying to read files using this url

svn://IPhost/usr/lib/folder/file.txt

The files are from the subversion repository..
I find it hard linking the files to my program.. The files and the source code is in the same repository.

thanks a lot...

No you need to use some http library and call httpOpen

I have already found the solution to my problem.. Anyway, thank you still for the reply....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.