Perhaps this is an indication that your API needs to be reworked slightly? In a generalized, transparent API like you're creating, maybe it's best not to *require* using relatively low-level methods like seek, open, read, etc.

In other words, perhaps you should be thinking of a way to unify the filesystem API and the FTP API; it seems you've been able to do so relatively well so far, but now you've hit a stopping point: so you should step back and think whether your API for this particular operation is really the best possible API.

If you can't seek FTP files, then why have a seek method in your API? That's specific to open filehandles, so it shouldn't be part of your general API.

As an alternative solution, consider this: maybe your

new
method, or your
open
method, should take an argument specifying where in the byte stream the file should be opened. The local-file implementation could then do
open FH, ... seek FH, ...
to get to the proper spot, and the FTP implementation could do
REST
or whatever it is that you need to do for FTP.

This approach might be sufficiently general that you won't get into the same problem of an implementation that cannot possibly fit into your API, because your API was not general enough to begin with.


In reply to Re: Polymorphic Abstraction of Disk versus FTP File Access: A Stumbling Block by btrott
in thread Polymorphic Abstraction of Disk versus FTP File Access: A Stumbling Block by princepawn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.