SFML community forums
Help => Network => Topic started by: vEjEsE on March 25, 2014, 05:57:26 pm
-
Hello,
Is there any way to find out if a path is directory or file?
The only way I figured is to try and changeDirectory() into every item of the listing returned, if it doesn't work, it's a file.
Is there any other, more applicable, check I could do?
Checking for a .extension of the string won't always work, folders can have dots, files may not have dots.
-
You could look into using <dirent.h>. I've used it for scanning directories for files and other directories. It's a plus, as it works on Windows and Linux, and I believe it works on OSX.
It's a C header, so you gotta deal with that if you haven't before, but it's not too difficult. If you decide to go that route and need pointers (pun intended), I can help with that.
Oops, sorry, I misunderstood. Won't work obviously.
-
Not at a PC now.
Quick question:
All I have is the sf::Ftp interface for the files on the remote server, and all it returns is sf::Ftp::Reponse.
How could I use the lib with that?
-
Of course you can't use any file system lib since you work on the remote FTP server. All you have is a bunch of FTP commands.
Unfortunately I don't think there is a command that clearly gives this information. As far as I know, FTP clients parse the non-standard information given by a command that returns information about files/folders (don't remember which one it is) to find if they are files or folders.
-
Unfortunately I don't think there is a command that clearly gives this information. As far as I know, FTP clients parse the non-standard information given by a command that returns information about files/folders (don't remember which one it is) to find if they are files or folders.
Which is why the IETF proposed RFC 3659 (http://tools.ietf.org/html/rfc3659). I think the abstract speaks for itself:
This document specifies new FTP commands to obtain listings of remote
directories in a defined format, and to permit restarts of
interrupted data transfers in STREAM mode. It allows character sets
other than US-ASCII, and also defines an optional virtual file
storage structure.
The command which would be useful in this scenario would be MLSD (http://tools.ietf.org/html/rfc3659#section-7). Don't ask me how many FTP servers have already implemented this. We all know how administrators live under a rock and only come out when things break ;).
-
I need to send a command to the server that gives me information that I shouldn't trust about whether it's a file or a folder.
How do FTP managers do it?
For sending a command to the server, can I extend the sf::Ftp class in order to add a "sendCommand" method?
-
Yes, why, yes it works.
I just have to use the "sendCommand" method. But it's private (why?).
Need to inherit in a weird manner.
Command:
NLST - Returns a list of file names in a specified directory.
Would help? Are directory considered files?
-
Wait, I can't get access to private method with inheritance. What was I talking about?
Would making "sendCommand" method protected be a bad suggestion?
-
Would making "sendCommand" method protected be a bad suggestion?
It should even be public ;)
-
Where do I submit that? Github?
For now, if I modify the header file (SFML/Network/Ftp.hpp) and move the method into public scope, would that be a bad idea?
-
Where do I submit that? Github?
In general, pull requests can be submitted on GitHub, yes.
But for things that are so tiny that they can be fixed within a matter of few minutes, the pull request overhead (commit, submit, review, edit, merge) is not worth the effort.
It's fixed now ;)
-
Yes, that makes sense. Thank you.
Last quick question:
Is SFML nightly build stable enough to use it in learning?
-
The nightly builds are quite outdated, I recommend using the latest Git revision. Especially because you want sf::Ftp::sendCommand() to be public, which I implemented only yesterday.