Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Python Virtual PC

Name: Anonymous 2008-04-23 9:35

I'm trying to make a virtual PC in python and need some help.  This virtual PC will be a console and you would be able to mess around a virtual file system.  I need some help on how to make this virtual file system.  So far I defined some files like this:

files = [
['page.txt','this is a test'],
['test.txt','another test'],
['lol.html','<html>\n</html>']
]

Where the first item would be the name of the file, and the second would be the contents.  I need some help on how to print it to the screen and how to make directory's.  Would this even be the right way of doing this or should I make files classes?

Name: Anonymous 2008-04-23 9:47

Basic data structures, DO YOU KNOW THEM?

Name: Anonymous 2008-04-23 9:49

Forget it, it's NP complete.

Name: Anonymous 2008-04-23 9:51

>>2
[i]virtual PC[i] As in not real files.

Name: Anonymous 2008-04-23 10:39

>>5
FAILED BBCODE DETECTED

Name: Anonymous 2008-04-23 10:44

>>6
lol xD u r so funeh

Name: Anonymous 2008-04-23 10:51

>>7
#1) you can't even use IRC well; #2) you can't tab-complete; #3) you can't google - this implies yer too busy jerking off and sucking soda or video-gaming. Die well, kid

Name: Anonymous 2008-04-23 10:52

>8
wut r u tlkn bout i dont jerk of wut iz irc

Name: Anonymous 2008-04-23 10:53

>>1
Have a tuple as a file and a list as a directory. Each directory list can contain more directory lists or file tuples. So then they can be arbitrarily nested.

Name: Anonymous 2008-04-23 10:55

I like how you failed to help the poor kid in 9 posts. Nice job assholes; this is where the party ends, I cant stand listening to you and your faggot friends.

Name: Anonymous 2008-04-23 10:58

I like how you failed to see YHBT within 9 posts. Nice job asshole; this is where the party ends, I cant stand listening to you and your faggot theories.

Name: Anonymous 2008-04-23 11:01

>>11
I just realised I didn't even read OP's post. Shows what I think of the quality of posts.

Name: Anonymous 2008-04-23 11:04

Ah; it was a troll or an idiot, anyway.

Name: Anonymous 2008-04-23 11:07

my anus was hacked and made big logs

Name: Anonymous 2008-04-23 11:49

>>11
Since I'm seeing a lot of these meta-troll posts, I'll go ahead and reply in the hopes that maybe the other two people posting here will read this.

Yes, there aren't a lot of ``helpful'' replies on /prog/. While you might like to attribute this ``fault'' to those who post the replies, doing such makes an incorrect assumption as to the nature of this board. Unlike other boards on other sites, /prog/ isn't about "halp me do this" or "halp me do that". We don't exist to give advice to people who, honestly, don't know enough about programming to help themselves.

/prog/ is all about abstract bullshite. Some acceptable topics are

 • Discussing the finer points of various type systems.
 • Debate over various algorithms.
 • Interesting code challenges, implementation analysis, etc.
 • Cult of Personality threads.
 • Bashing Python THE FORCED INDENTATION OF THE CODE.

This topic in particular, as mentioned in >>3-4,14 is ``either an idiot or a troll''. The content of the post describes a fairly mundane approach to a specific part of a considerably larger problem. It overlooks many important considerations, and shows a complete lack of either forethought or design.

It isn't quite clear from a first reading what specifically >>1 wants. In the post, >>1 banters on about a Virtual PC. This leads the reader to assume that the question is going to be related somehow to some sort of hardware emulation. As it turns out, this isn't related in any way to the question, which is how to implement a virtual file system. The banter about VM implementations should be omitted entirely from the post.

Looking past that, it still isn't clear what the OP wants from us. He poses a variety of questions --

how to print it to the screen
how to make directory's
should I make files classes

Each of these questions is completely separate from the others; two of them have absolutely nothing to do with the actual high-level structure of the virtual filesystem. Given the context of "virtual filesystem questions", the only valid question is the second, which was answered fairly well by >>10.

The other two questions demonstrate a complete lack of knowledge. List serialization in Python is trivial and built-in.  Specific serializations can be done with an iteration over the list. Ultimately, the reader is unsure of what the OP wants -- there are a myriad of ways the tree can be output to the console, whether it's output as a fully-expanded tree, or if it's output from the perspective of a given node.

The last question, really, is the kicker. While standing on shaky ground, the OP rhetorically questions everything he's done so far. Such udder lack of self-confidence shows that he hasn't given enough care into this project to even try to answer his own questions.

Ultimately, it is not /prog/ which is unhelpful. We help those who help themselves. If you want to have a serious discussion, start a serious discussion. Don't come crawling to us about your stupid bullshit -- we have enough of that already.

Thanks for reading,
Christopher.

Name: Anonymous 2008-04-23 12:13

>>16
You used a hefty post to convey a message that would fit in three sentences. I hate people like you, Christopher.

Name: Anonymous 2008-04-23 12:32

>>17
I use real “Unicode quotes”, not this fail ``substitute''.

Name: Anonymous 2008-04-23 12:36

files = [
['hax.txt','this is the hax code'],
['my.txt','who to hax'],
['anus.html','what to hax']
]

Name: Anonymous 2008-04-23 18:37

>>18
You can tune a file system, but ``these are the real quotes.''

Name: Anonymous 2008-04-23 18:41


files = [
    ['A:',
        ['usr',
            ['file.txt','This is a test!'],
            ['test.html','<html>\nTEST\n</html>'],
            ['desktop',
                ['file_a.txt','sup?'],
                ['file_b.txt','SUP?']
            ]
        ],
        ['sys',
            ['kernel.bin'],
            ['os.bin']
        ]
    ]
]

Name: Anonymous 2008-04-23 19:06

>>16
The acceptable topics list is inaccurate, but nobody cares. Your analysis on >>1's post is worth a YHBT.

>>21
Oh.. god..

Name: Anonymous 2008-04-23 19:16

>>16
You are fucking Chris Webster and I know it. I hate you, you fucking prick.

Wanker,
[strong]Anon[/strong]

Name: Anonymous 2008-04-23 19:23

>>23
Anon

Name: Anonymous 2008-04-23 23:44

You might want to browse through linux source code, they have some good examples (in C though).

Name: Anonymous 2008-04-24 0:26

You could create a virtual disk as an array of blocks, where each block is just an array of bytes of a fixed size (say 256 bytes).

Then make a simple file table, with a fixed number of entries, where each entry is a block number (ie. an index into the disk's block array). Make each file occupy 1 block, with say 32 bytes for the name, 4 bytes for the size, and the rest used to store the file contents. This gives you a simple 1-level filesystem, where 1 file = 1 block = 256 bytes.

From there, you could introduce some indirection by making the files contain pointers to other blocks instead of directly storing data. That increases the maximum filesize.

Then you could introduce a flag into files that indicate whether they represent a directory. If the flag is true, then the file's data pointers point to the files contained in the directory.

You could also think about how your virtual disk is going to track which blocks are used and which are free, how you're going to handle deletions, etc.

Name: Anonymous 2008-04-24 1:38

>>16 is unscientific and ultimately destructive.

Name: Anonymous 2008-04-24 3:04

OP here, thanks >>26, very helpful.

honestly. believe me.

Name: Anonymous 2008-04-24 5:18

>>26
Why would you bother doing that, just let Python collect the garbage for you when you delete a file, rather than tracking which blocks in an array are unused.

Name: Anonymous 2008-04-24 21:12

>>29
I was trying to lead into thinking about file fragmentation, different allocation strategies, etc. But if your virtual disk is modelled as a simple array, those issues are not very obvious.

So yeah, you're right.

Name: Anonymous 2011-02-04 19:11

Name: Sgt.Kabukiman䖉 2012-05-22 23:17

All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy
 All work and no play makes Jack a dull boy

Name: Anonymous 2013-11-28 11:36

>─────▄████▀█▄
   >───▄█████████████████▄
   >─▄█████.▼.▼.▼.▼.▼.▼▼▼▼
   >▄███████▄.▲.▲▲▲▲▲▲▲▲
   >███████████████████▀▀
   YOU HAVE BEEN CAUGHT BY THE GATOR OF DOOM! REPOST THIS 5 TIMES OR GET GATORED!!!
>─────▄████▀█▄
   >───▄█████████████████▄
   >─▄█████.▼.▼.▼.▼.▼.▼▼▼▼
   >▄███████▄.▲.▲▲▲▲▲▲▲▲
   >███████████████████▀▀
   YOU HAVE BEEN CAUGHT BY THE GATOR OF DOOM! REPOST THIS 5 TIMES OR GET GATORED!!!
>─────▄████▀█▄
   >───▄█████████████████▄
   >─▄█████.▼.▼.▼.▼.▼.▼▼▼▼
   >▄███████▄.▲.▲▲▲▲▲▲▲▲
   >███████████████████▀▀
   YOU HAVE BEEN CAUGHT BY THE GATOR OF DOOM! REPOST THIS 5 TIMES OR GET GATORED!!!
>─────▄████▀█▄
   >───▄█████████████████▄
   >─▄█████.▼.▼.▼.▼.▼.▼▼▼▼
   >▄███████▄.▲.▲▲▲▲▲▲▲▲
   >███████████████████▀▀
   YOU HAVE BEEN CAUGHT BY THE GATOR OF DOOM! REPOST THIS 5 TIMES OR GET GATORED!!!
>─────▄████▀█▄
   >───▄█████████████████▄
   >─▄█████.▼.▼.▼.▼.▼.▼▼▼▼
   >▄███████▄.▲.▲▲▲▲▲▲▲▲
   >███████████████████▀▀
   YOU HAVE BEEN CAUGHT BY THE GATOR OF DOOM! REPOST THIS 5 TIMES OR GET GATORED!!!
>─────▄████▀█▄
   >───▄█████████████████▄
   >─▄█████.▼.▼.▼.▼.▼.▼▼▼▼
   >▄███████▄.▲.▲▲▲▲▲▲▲▲
   >███████████████████▀▀
   YOU HAVE BEEN CAUGHT BY THE GATOR OF DOOM! REPOST THIS 5 TIMES OR GET GATORED!!!

Don't change these.
Name: Email:
Entire Thread Thread List